1 4 package com.tc.aspectwerkz.hook; 5 6 import java.io.InputStream ; 7 import java.io.OutputStream ; 8 9 15 class StreamRedirectThread extends Thread { 16 private static final int BUFFER_SIZE = 2048; 17 18 private static final int SLEEP = 5; 19 20 private InputStream is; 21 22 private OutputStream os; 23 24 public StreamRedirectThread(String name, InputStream is, OutputStream os) { 25 super(name); 26 setPriority(Thread.MAX_PRIORITY - 1); 27 this.is = is; 28 this.os = os; 29 } 30 31 public void run() { 32 byte[] buf = new byte[BUFFER_SIZE]; 33 int i; 34 try { 35 while ((i = is.read(buf)) > 0) { 36 os.write(buf, 0, i); 37 try { 38 Thread.sleep(SLEEP); 39 } catch (InterruptedException e) { 40 ; 41 } 42 } 43 } catch (Exception e) { 44 ; 45 } finally { 46 ; } 48 } 49 50 58 } | Popular Tags |