网站管理后台下载,wordpress建站吧,巅云建站,网站建设属于什么工作java读取操作系统环境变量import java.util.*;import java.io.*;class SysProb{//返回当前系统变量的函数#xff0c;结果放在一个Properties里边#xff0c;这里只针对win2k以上的#xff0c;其它系统可以自己改进public Properties getEnv() throws Exception{Properties …java读取操作系统环境变量import java.util.*;import java.io.*;class SysProb{//返回当前系统变量的函数结果放在一个Properties里边这里只针对win2k以上的其它系统可以自己改进public Properties getEnv() throws Exception{Properties propnew Properties();String OS System.getProperty(os.name).toLowerCase();Process pnull;if(OS.indexOf(windows)-1){pRuntime.getRuntime().exec(cmd /c set); //其它的操作系统可以自行处理 我这里是win2k}BufferedReader brnew BufferedReader(newInputStreamReader(p.getInputStream()));String line;while((linebr.readLine())!null){int iline.indexOf();if(i-1){String keyline.substring(0,i);String valueline.substring(i1);prop.setProperty(key,value);}}return prop;}//具体用法public static void main(String[] args){try{SysProb spnew SysProb();Properties psp.getEnv();System.out.println(p.getProperty(Path)); //注意大小写如果写成path就不对了}catch(Exception e){System.out.println(e);}}}更多java读取操作系统环境变量相关文章请关注PHP中文网本文原创发布php中文网转载请注明出处感谢您的尊重