01: /* CVS ID: $Id: StreamConnector.java,v 1.1.1.1 2002/10/02 18:42:49 wastl Exp $ */
02: package net.wastl.webmail.misc;
03:
04: import net.wastl.webmail.server.*;
05: import java.io.*;
06:
07: /**
08: * StreamConnector.java
09: *
10: * Created: Tue Sep 7 14:47:10 1999
11: *
12: * Copyright (C) 2000 Sebastian Schaffert
13: *
14: * This program is free software; you can redistribute it and/or
15: * modify it under the terms of the GNU General Public License
16: * as published by the Free Software Foundation; either version 2
17: * of the License, or (at your option) any later version.
18: *
19: * This program is distributed in the hope that it will be useful,
20: * but WITHOUT ANY WARRANTY; without even the implied warranty of
21: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22: * GNU General Public License for more details.
23: *
24: * You should have received a copy of the GNU General Public License
25: * along with this program; if not, write to the Free Software
26: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27: */
28: /**
29: * Used to write to a OutputStream in a separate Thread to avoid blocking.
30: *
31: * @author Sebastian Schaffert
32: * @version
33: */
34: public class StreamConnector extends Thread {
35:
36: InputStream in;
37: ByteStore b;
38: int size;
39: boolean ready = false;
40:
41: public StreamConnector(InputStream sin, int size) {
42: super ();
43: in = sin;
44: this .size = size;
45: b = null;
46: this .start();
47: }
48:
49: public void run() {
50: b = ByteStore.getBinaryFromIS(in, size);
51: ready = true;
52: }
53:
54: public ByteStore getResult() {
55: while (!ready) {
56: try {
57: sleep(500);
58: System.err.print(".");
59: } catch (InterruptedException ex) {
60: }
61: }
62: System.err.println();
63: return b;
64: }
65:
66: } // StreamConnector
|