Home > Back-end >  The ProcessBuilder execution echo with a newline
The ProcessBuilder execution echo with a newline

Time:10-13

As the code below, the ProcessBuilder execution echo -n '123 \ n456 | the cut - c2-3 will be submitted to the Unmatched'., want to question the following great god is there any way to solve, thank you,
 String comArray []=new String [] {"/bin/CSH ", "- the cf", "echo -n '123 \ n456 | the cut - c2-3"}; 
StringBuffer sb=new StringBuffer();
The ProcessBuilder builder=new ProcessBuilder (comArray);

Builder. RedirectErrorStream (true);
Process Process=builder. The start ();

InputStream input=process. GetInputStream ();
InputStreamReader isr=new InputStreamReader (input, "GBK");
BufferedReader br=new BufferedReader (isr);
The String line="";
while ((line=br.readLine()) !=null) {
Sb. Append (line + "\ n");

}
br.close();
System. The out. Println (sb. ToString ());
  • Related