JAVA调用shell

  StringBuilder result = new StringBuilder();
  
  InputStream in = proc.getInputStream();
  BufferedReader buf = new BufferedReader(new InputStreamReader(in, "gbk"));
  String line = null;
  while ((line = buf.readLine()) != null){
   result.append(line).append("\r\n");   
  }
  buf.close();
  proc.destroy();
  
  // 判断返回数据是否正确
  if (result.indexOf("failed") == -1){
   System.out.println("> success");
  } else {
   System.out.println("> failed");
  }

你可能感兴趣的:(shell,java)