日期:2014-05-16 浏览次数:20654 次
package test.runtime; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class RuntimeTest { /** * @param args */ public static void main(String[] args) { try { String[] cmd = {"sh","-c", "du -h /opt/apache*"}; Process chmodProcess = Runtime.getRuntime().exec(cmd); BufferedReader br = new BufferedReader(new InputStreamReader(chmodProcess.getInputStream())); String line =null; while((line = br.readLine() )!= null) { System.out.println(line); } System.out.println("end"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }?