In cmd.exe I try this :
echo " read "book <init>""
The error is :
The system cannot find the file specified.
It works with
echo "read "book ^<init^>""
But if I want to send as argument from java, it will not work:
String s4 = "read \"book ^<init^> \"" ;
How can I escape < > for cmd from java?
Full code :
public static void main(String[] args) throws IOException, InterruptedException{
List<String> paramsArray = new ArrayList<String>();
String s = "read \"book ^<init^> \"" ;
paramsArray.add("exec.cmd"); //cmd file that only has echo %*
paramsArray.add(s);
ProcessBuilder process = new ProcessBuilder(paramsArray).inheritIO();
Process p = process.start();
int exitStatus = p.waitFor();
System.out.println("exitStatus is " + exitStatus);
if (exitStatus == 0)
{
System.out.println("Ok!");
}
else{
System.out.println("Not ok!");
}
}