import java.io.*; public class Program01 { public static void main(String args[]) { String s = null; try { Process p = Runtime.getRuntime().exec("ls"); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); // kimenet olvasása: System.out.println("A alapértelmezett kimenet:\n"); while ((s = stdInput.readLine()) != null) { System.out.println(s); } // hibakimenet olvasása: System.out.println("Az alapértelmezett kimenet:\n"); while ((s = stdError.readLine()) != null) { System.out.println(s); } System.exit(0); }catch (IOException e){ System.out.println("Hiba történt - Oka: "); e.printStackTrace(); System.exit(-1); } } }