home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / java / io / PipedOutputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  1.2 KB  |  55 lines

  1. package java.io;
  2.  
  3. public class PipedOutputStream extends OutputStream {
  4.    private PipedInputStream sink;
  5.    boolean connected = false;
  6.  
  7.    public PipedOutputStream(PipedInputStream var1) throws IOException {
  8.       this.connect(var1);
  9.    }
  10.  
  11.    public PipedOutputStream() {
  12.    }
  13.  
  14.    public void connect(PipedInputStream var1) throws IOException {
  15.       if (!this.connected && !var1.connected) {
  16.          this.sink = var1;
  17.          var1.closed = false;
  18.          var1.in = -1;
  19.          var1.out = 0;
  20.          this.connected = true;
  21.       } else {
  22.          throw new IOException("Already connected");
  23.       }
  24.    }
  25.  
  26.    public void write(int var1) throws IOException {
  27.       this.sink.receive(var1);
  28.    }
  29.  
  30.    public void write(byte[] var1, int var2, int var3) throws IOException {
  31.       this.sink.receive(var1, var2, var3);
  32.    }
  33.  
  34.    public synchronized void flush() throws IOException {
  35.       if (this.sink != null) {
  36.          PipedInputStream var1 = this.sink;
  37.          synchronized(var1){}
  38.  
  39.          try {
  40.             this.sink.notifyAll();
  41.          } catch (Throwable var3) {
  42.             throw var3;
  43.          }
  44.  
  45.       }
  46.    }
  47.  
  48.    public void close() throws IOException {
  49.       if (this.sink != null) {
  50.          this.sink.receivedLast();
  51.       }
  52.  
  53.    }
  54. }
  55.