锘??xml version="1.0" encoding="utf-8" standalone="yes"?>日韩一区二区中文,国产99精品,国内精品久久久久影院薰衣草 http://www.aygfsteel.com/lucia/category/3312.htmlzh-cnThu, 01 Mar 2007 00:02:20 GMTThu, 01 Mar 2007 00:02:20 GMT60Access user defined environment variable inside the java program with jdk1.4http://www.aygfsteel.com/lucia/archive/2005/09/14/12951.htmllucialuciaTue, 13 Sep 2005 18:36:00 GMThttp://www.aygfsteel.com/lucia/archive/2005/09/14/12951.htmlhttp://www.aygfsteel.com/lucia/comments/12951.htmlhttp://www.aygfsteel.com/lucia/archive/2005/09/14/12951.html#Feedback0http://www.aygfsteel.com/lucia/comments/commentRss/12951.htmlhttp://www.aygfsteel.com/lucia/services/trackbacks/12951.html import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
* Environment class simulates the System.getenv() method which is deprecated
* on java 1.4.2
*
* @author v-josp
*
*/
public class TestRoot
{
//result of all enviornment variables
private static BufferedReader commandResult;

static
{
String cmd = null;
String os = null;

//getting the OS name
os = System.getProperty("os.name").toLowerCase();

// according to OS set the command to execute
if(os.startsWith("windows"))
{
cmd = "cmd /c SET";
}
else
{
cmd="env";
}

try
{
//execute the command and get the result in the form of InputStream
Process p = Runtime.getRuntime().exec(cmd);

//parse the InputStream data
InputStreamReader isr = new InputStreamReader(p.getInputStream());
commandResult= new BufferedReader(isr);
}
catch (Exception e)
{
System.out.println("OSEnvironment.class error: " + cmd + ":" + e);
}
}

/**
* This method is used to get the path of the given enviornment variable. This
* method tries to simulates the System.getenv() which is deprecated on java 1.4.2
*
* @param String - name of the environment variable
* @param String - default value
* @return
*/
public static String getenv(String envName,String defaultValue)
{
String line = null;
try
{
while ((line = commandResult.readLine()) != null)
{
if(line.indexOf(envName)>-1)
{
return line.substring(line.indexOf(envName)+envName.length()+1);
}
}
return defaultValue;
}
catch (Exception e)
{
return defaultValue;
}
}

public static void main(String args[])
{
System.out.println(TestRoot.getenv("CLASSPATH",""));
}
}

Output
_____
F:\software\javaws-1_2-dev\jnlp.jar;


lucia 2005-09-14 02:36 鍙戣〃璇勮
]]>
How to get the the currect path where program runs?http://www.aygfsteel.com/lucia/archive/2005/09/10/12637.htmllucialuciaSat, 10 Sep 2005 14:12:00 GMThttp://www.aygfsteel.com/lucia/archive/2005/09/10/12637.htmlhttp://www.aygfsteel.com/lucia/comments/12637.htmlhttp://www.aygfsteel.com/lucia/archive/2005/09/10/12637.html#Feedback0http://www.aygfsteel.com/lucia/comments/commentRss/12637.htmlhttp://www.aygfsteel.com/lucia/services/trackbacks/12637.htmltry {
File currDir = new File (".");
System.out.println("Dir: " + currDir.getCanonicalPath());
}
catch (IOException ex){
//
}




lucia 2005-09-10 22:12 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 阳江市| 平昌县| 普安县| 伊通| 颍上县| 嵩明县| 皋兰县| 交城县| 卓资县| 珠海市| 盐边县| 恭城| 建德市| 宁晋县| 万荣县| 扎赉特旗| 大安市| 河间市| 乌兰县| 鹤庆县| 龙口市| 丰镇市| 巴塘县| 新泰市| 吉林市| 清水县| 宁都县| 葵青区| 淳化县| 惠安县| 临武县| 武乡县| 偃师市| 西昌市| 西乌| 布尔津县| 星子县| 东至县| 聊城市| 册亨县| 博罗县|