执行系统命令

private String excuteCommandWithResult(String command) { String res=""; String line; try { Process p = Runtime.getRuntime().exec(command); BufferedReader input = new BufferedReader (new InputStreamReader(p.getInputStream())); while ((line = input.readLine()) != null) { res+=line; System.out.println(line); } input.close(); } catch (Exception e) { // TODO: handle exception } return res; }  

你可能感兴趣的:(执行系统命令)