I have code which has to read a bat file and run it. But path contains Space how we can read space in java in file path. Below is the code
String cmd5 = "cmd /c start E://Test 1.4.3/start.bat";
Process p5 = Runtime.getRuntime().exec(cmd5);
I have code which has to read a bat file and run it. But path contains Space how we can read space in java in file path. Below is the code
String cmd5 = "cmd /c start E://Test 1.4.3/start.bat";
Process p5 = Runtime.getRuntime().exec(cmd5);
Try
String cmd5 = "cmd /c \"E:\\Test 1.4.3\\start.bat\""
You can try quotes around it
String cmd5 = "cmd.exe /c start \"E:/Test 1.4.3/start.bat\"";
Process p5 = Runtime.getRuntime().exec(cmd5);
or a string array
String[] cmd5s = { "cmd.exe", "/c", "start", "E:/Test 1.4.3/start.bat" };
Process p5 = Runtime.getRuntime().exec(cmd5s);
For the rest ProcessBuilder is nicer in usage than Runtime.