Reading windows environment variable in java
import java.io.*;
public class Test{
public static void main(String args[]) throws IOException{
//JDK1.5
System.out.println(System.getenv("USERDOMAIN"));
//Pre-JDK1.5
Process p = Runtime.getRuntime().exec("cmd.exe /c echo %USERDOMAIN%");
BufferedReader br = new BufferedReader
( new InputStreamReader( p.getInputStream() ) );
String myvar = br.readLine();
System.out.println(myvar);
}
}
public class Test{
public static void main(String args[]) throws IOException{
//JDK1.5
System.out.println(System.getenv("USERDOMAIN"));
//Pre-JDK1.5
Process p = Runtime.getRuntime().exec("cmd.exe /c echo %USERDOMAIN%");
BufferedReader br = new BufferedReader
( new InputStreamReader( p.getInputStream() ) );
String myvar = br.readLine();
System.out.println(myvar);
}
}
1 Comments:
At 4:05 PM , Uzi said...
I must appriciate the spamming and advertisement efforts people are making....even blogger has become a victim! :X
Post a Comment
Subscribe to Post Comments [Atom]
<< Home