代码如下
[code="java"]
Runtime run = Runtime.getRuntime();
Process prs = run.exec("echo 'hello' >/root/123.txt");
OutputStream out = prs.getOutputStream();
InputStream in = prs.getInputStream();
InputStream err = prs.getErrorStream();
byte[] er = new byte[1024];
byte[] b = new byte[1024] ;
//in.read(b);
while(in.read(b)>0){
System.out.println(new String(b));
}
System.out.println(prs.waitFor());
[/code]
waitFor 返回为0表示成功可是我在/root/下找补到123.txt
希望大家给予帮助谢谢