1 11 package org.eclipse.update.internal.jarprocessor; 12 13 import java.io.BufferedReader ; 14 import java.io.IOException ; 15 import java.io.InputStream ; 16 import java.io.InputStreamReader ; 17 18 public class StreamProcessor extends Thread { 19 public static final String STDERR = "STDERR"; public static final String STDOUT = "STDOUT"; 22 private InputStream inputStream; 23 private String name; 24 private boolean verbose; 25 26 public StreamProcessor(InputStream is, String name, boolean verbose) { 27 this.inputStream = is; 28 this.name = name; 29 this.verbose = verbose; 30 } 31 32 public void run() { 33 try { 34 InputStreamReader isr = new InputStreamReader (inputStream); 35 BufferedReader br = new BufferedReader (isr); 36 while (true) { 37 String s = br.readLine(); 38 if (s == null) { 39 break; 40 } 41 if (verbose) { 42 if (STDERR.equals(name)) 43 System.err.println(name + ": " + s); else 45 System.out.println(name + ": " + s); } 47 } 48 } catch (IOException e) { 49 e.printStackTrace(); 50 } 51 } 52 53 } 54 | Popular Tags |