1 4 package com.tc.util.io; 5 6 import com.tc.exception.TCRuntimeException; 7 8 import java.io.BufferedInputStream ; 9 import java.io.BufferedOutputStream ; 10 import java.io.InputStream ; 11 import java.io.OutputStream ; 12 13 public class StreamHandler implements Runnable { 14 InputStream in; 15 OutputStream out; 16 17 public StreamHandler(InputStream in, OutputStream out) { 18 this.in = in; 19 this.out = out; 20 } 21 22 public void run() { 23 BufferedInputStream bin = new BufferedInputStream (in); 24 BufferedOutputStream bout = new BufferedOutputStream (out); 25 int i; 26 try { 27 while ((i = bin.read()) != -1) { 28 bout.write(i); 29 } 30 bout.flush(); 31 } catch (Exception e) { 32 throw new TCRuntimeException(e); 33 } 34 } 35 } | Popular Tags |