How to perform a local program and capture OUT and ERR output (Written in Java)

xiaoxiao2021-03-06  90

Import java.io.bufferedreader; import java.io ioException; import java.io.inputstreamReader;

public class TestInOutErr {public static void main (String [] args) throws IOException {Process p = Runtime.getRuntime () exec ( "java AppTest");. BufferedReader in = new BufferedReader (new InputStreamReader (p.getInputStream ())) ; String currentLine = null; while (! (currentLine = in.readLine ()) = null) System.out.println (currentLine); BufferedReader err = new BufferedReader (new InputStreamReader (p.getErrorStream ())); while (( Currentline = Err.Readline ())! = null) System.out.println (Currentline);}}

转载请注明原文地址:https://www.9cbs.com/read-107597.html

New Post(0)