Java调用shell
try {
String commands = "ls -l";
Process process = Runtime.getRuntime().exec (commands);
// for showing the info on screen
InputStreamReader ir=new
InputStreamReader(process.getInputStream());
BufferedReader input = new BufferedReader (ir);
String line;
while ((line = input.readLine ()) != null){
System.out.println(line);
}//end try
}
catch (java.io.IOException e){
System.err.println ("IOException " + e.getMessage());
}
posted on 2016-01-26 15:16 1130136248 阅读(87) 评论(0) 编辑 收藏 举报