01: /*
02: * StreamHandler.java
03: *
04: * Created on 08 May 2006, 10:16
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package org.netbeans.test.subversion.utils;
11:
12: import java.io.BufferedInputStream;
13: import java.io.BufferedOutputStream;
14: import java.io.IOException;
15: import java.io.InputStream;
16: import java.io.OutputStream;
17:
18: /**
19: *
20: * @author peter
21: */
22: public class StreamHandler extends Thread {
23:
24: InputStream in;
25: OutputStream out;
26:
27: /** Creates a new instance of StreamHandler */
28: public StreamHandler(InputStream in, OutputStream out) {
29: this .in = new BufferedInputStream(in);
30: this .out = new BufferedOutputStream(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 ex) {
49: ex.printStackTrace();
50: }
51: }
52: }
|