1 package com.openedit.archive.update; 2 3 import java.io.BufferedReader ; 4 import java.io.IOException ; 5 import java.io.InputStream ; 6 import java.io.InputStreamReader ; 7 import java.util.Vector ; 8 9 import org.apache.commons.logging.Log; 10 import org.apache.commons.logging.LogFactory; 11 12 class StreamGobbler extends Thread { 13 private static final Log log = LogFactory.getLog(StreamGobbler.class); 14 15 InputStream is; 16 17 String type; 18 19 Vector output; 20 21 StreamGobbler(InputStream is, String type, Vector collectingParameter) { 22 this.is = is; 23 this.type = type; 24 this.output = collectingParameter; 25 } 26 27 public void run() { 28 try { 29 BufferedReader reader = new BufferedReader ( 30 new InputStreamReader (is)); 31 String line = null; 32 while ((line = reader.readLine()) != null) 33 output.addElement(type + ">" + line); 34 } catch (IOException x) { 35 String out = type + "> error: " + x.getMessage(); 36 output.addElement(out); 37 log.error(out); 38 } 39 } 40 } 41 | Popular Tags |