I need to execute some line command in my java program. For example, I want to go to a directory and then create a folder in it like this:
cd C:\\Users\\qi11091\\Documents\\TITAN_Command_Line\\FirstTest
mkdir toto
My probem is that I can do the first command, it works but I don't know how to do the second command in my Program.
Here is my code
public void TtcnToC(String path){
System.out.println("Début du programme");
try{
System.out.println("Path target verification: "+path);
String[] mkdir = {"cmd.exe", "/c","cd C:\\Users\\qi11091\\Documents\\TITAN_Command_Line\\FirstTest", "mkdir titi"};
String[] mkdir1 = {"cmd.exe", "/c","cd "+ path};
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(mkdir1);
//Process process1 = runtime.exec(mkdir1);
//Process process2 = runtime.exec(mkdir2);
BufferedReader output = getOutput(process);
BufferedReader error = getError(process);
String ligne = "";
while ((ligne = output.readLine()) != null) {
System.out.println(ligne);
}
while ((ligne = error.readLine()) != null) {
System.out.println(ligne);
}
System.out.println("in the shell");
process.waitFor();
}