home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / NetPipedOutputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  1.4 KB  |  46 lines

  1. package symantec.itools.db.net;
  2.  
  3. import java.io.IOException;
  4. import java.io.OutputStream;
  5.  
  6. class NetPipedOutputStream extends OutputStream {
  7.    private NetPipedInputStream sink;
  8.  
  9.    public NetPipedOutputStream(NetPipedInputStream snk) throws IOException {
  10.       this.connect(snk);
  11.    }
  12.  
  13.    public NetPipedOutputStream() {
  14.    }
  15.  
  16.    public void connect(NetPipedInputStream snk) throws IOException {
  17.       this.sink = snk;
  18.       snk.closed = false;
  19.       snk.connbroken = false;
  20.       snk.in = -1;
  21.       snk.out = 0;
  22.    }
  23.  
  24.    public void write(int b) throws IOException {
  25.       this.sink.receive(b);
  26.    }
  27.  
  28.    public void write(byte[] b, int off, int len) throws IOException {
  29.       this.sink.receive(b, off, len);
  30.    }
  31.  
  32.    public void close() throws IOException {
  33.       if (this.sink != null) {
  34.          this.sink.receivedLast();
  35.       }
  36.  
  37.    }
  38.  
  39.    void breakConn() throws IOException {
  40.       if (this.sink != null) {
  41.          this.sink.connBroken();
  42.       }
  43.  
  44.    }
  45. }
  46.