KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > util > io > StreamHandler


1 /**
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

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