package files; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class TestStreamOfProcess { public static void main(String[] args) throws IOException { // Process process = new ProcessBuilder("java -version".split(" ")).start(); Process process = Runtime.getRuntime().exec("java"); BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); String str = null; while ((str = br.readLine()) != null) { System.out.println(str); } BufferedReader brError = new BufferedReader(new InputStreamReader(process.getErrorStream())); str = null; while ((str = br.readLine()) != null) { System.out.println(brError); } } }