KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > remoting > CopyThread


1 package hudson.remoting;
2
3 import java.io.InputStream JavaDoc;
4 import java.io.OutputStream JavaDoc;
5 import java.io.IOException JavaDoc;
6
7 /**
8  * Thread that copies a stream.
9  *
10  * @author Kohsuke Kawaguchi
11  */

12 class Copier extends Thread JavaDoc {
13     private final InputStream JavaDoc in;
14     private final OutputStream JavaDoc out;
15
16     public Copier(String JavaDoc threadName, InputStream JavaDoc in, OutputStream JavaDoc out) {
17         super(threadName);
18         this.in = in;
19         this.out = out;
20     }
21
22     public void run() {
23         try {
24             byte[] buf = new byte[8192];
25             int len;
26             while((len=in.read(buf))>0)
27                 out.write(buf,0,len);
28             in.close();
29         } catch (IOException JavaDoc e) {
30             // TODO: what to do?
31
}
32     }
33 }
34
Popular Tags