Hi,
i have problem using Runtime.getRuntime() to change working directory and then list it
anyone know how to do it
basically i want 2 things to be done
1. cd c:/exploded-temp
2. dir /w
below is my partial code
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2] = "cd C:/exploded-temp";
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(cmd);
// any error message?
StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR");
// any output?
StreamGobbler outputGobbler = new
StreamGobbler(proc.getInputStream(), "OUTPUT");
// kick them off
errorGobbler.start();
outputGobbler.start();
// any error???
int exitVal = proc.waitFor();
System.out.println("ExitValue: " + exitVal);
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2] = "dir /w";
proc = rt.exec(cmd);
errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR");
// any output?
outputGobbler = new
StreamGobbler(proc.getInputStream(), "OUTPUT");
// kick them off
errorGobbler.start();
outputGobbler.start();
but the code above seems doesnt work
it only list whatever directory i run this java class from
anyone know how to solve it?
thanks