KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > subversion > utils > StreamHandler


1 /*
2  * StreamHandler.java
3  *
4  * Created on 08 May 2006, 10:16
5  *
6  * To change this template, choose Tools | Template Manager
7  * and open the template in the editor.
8  */

9
10 package org.netbeans.test.subversion.utils;
11
12 import java.io.BufferedInputStream JavaDoc;
13 import java.io.BufferedOutputStream JavaDoc;
14 import java.io.IOException JavaDoc;
15 import java.io.InputStream JavaDoc;
16 import java.io.OutputStream JavaDoc;
17
18 /**
19  *
20  * @author peter
21  */

22 public class StreamHandler extends Thread JavaDoc {
23
24     InputStream JavaDoc in;
25     OutputStream JavaDoc out;
26     
27     /** Creates a new instance of StreamHandler */
28     public StreamHandler(InputStream JavaDoc in, OutputStream JavaDoc out) {
29         this.in = new BufferedInputStream JavaDoc(in);
30         this.out = new BufferedOutputStream JavaDoc(out);
31     }
32     
33     public void run () {
34         try {
35             try {
36                 try {
37                     int i;
38                     while((i = in.read()) != -1) {
39                         out.write(i);
40                     }
41                 } finally {
42                     in.close();
43                 }
44                 out.flush();
45             } finally {
46                 out.close();
47             }
48         } catch (IOException JavaDoc ex) {
49           ex.printStackTrace();
50         }
51     }
52 }
53
Popular Tags