java.io

Class PipedOutputStream

Implemented Interfaces:
Closeable, Flushable

public class PipedOutputStream
extends OutputStream

A piped output stream can be connected to a piped input stream to create a communications pipe. The piped output stream is the sending end of the pipe. Typically, data is written to a PipedOutputStream object by one thread and data is read from the connected PipedInputStream by some other thread. Attempting to use both objects from a single thread is not recommended as it may deadlock the thread.
Since:
JDK1.0
See Also:
PipedInputStream

Constructor Summary

PipedOutputStream()
Creates a piped output stream that is not yet connected to a piped input stream.
PipedOutputStream(PipedInputStream snk)
Creates a piped output stream connected to the specified piped input stream.

Method Summary

void
close()
Closes this piped output stream and releases any system resources associated with this stream.
void
connect(PipedInputStream snk)
Connects this piped output stream to a receiver.
void
flush()
Flushes this output stream and forces any buffered output bytes to be written out.
void
write(b[] , int off, int len)
Writes len bytes from the specified byte array starting at offset off to this piped output stream.
void
write(int b)
Writes the specified byte to the piped output stream.

Methods inherited from class java.io.OutputStream

close, flush, write, write, write

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

PipedOutputStream

public PipedOutputStream()
Creates a piped output stream that is not yet connected to a piped input stream. It must be connected to a piped input stream, either by the receiver or the sender, before being used.
Usages and Demos :

View More Examples of PipedOutputStream()
   1: 
   2:         PipedOutputStream pipeOut = new PipedOutputStream();
   3:         PipedInputStream pipeIn = new PipedInputStream(pipeOut);
   4:         ...
   5: 
   6:         PipedOutputStream pipeOut = new PipedOutputStream();
   7:         PipedInputStream pipeIn = new PipedInputStream(pipeOut);
   8:         PrintStream out = new PrintStream(pipeOut);

View Full Code Here
   1:             PipedInputStream pin = new PipedInputStream();
   2:             PipedOutputStream pout = new PipedOutputStream();
   3:             pout.connect( pin);
   4:             new PipeSender(pout,"sendString").start();
   5:             new PipeReciver(pin,"receiveString").start();

View Full Code Here
   1:     public ProtocolLayerPipe() throws IOException {
   2:         PipedOutputStream pipedOutputStream1 = new PipedOutputStream();
   3:         ...
   4:         PipedOutputStream pipedOutputStream2 = new PipedOutputStream();
   5:         PipedInputStream pipedInputStream1 = new PipedInputStream(
   6:                 pipedOutputStream2);
   7:         PipedInputStream pipedInputStream2 = new PipedInputStream(

View Full Code Here
   1:         PipedInputStream si = new PipedInputStream();
   2:         PipedOutputStream co = new PipedOutputStream();
   3:         ...
   4:         PipedOutputStream so = new PipedOutputStream();
   5:         ci.connect(so);
   6:         si.connect(co);
   7:         client_input = ci;

View Full Code Here
   1:     IclTerm q = IclTerm.fromString(QUOTEDMARK);
   2:     PipedOutputStream pos = new PipedOutputStream();
   3:     PipedInputStream pis = new PipedInputStream();
   4:         ...
   5:     IclTerm q = IclTerm.fromString(QUOTEDMARK);
   6:     PipedOutputStream pos = new PipedOutputStream();
   7:     PipedInputStream pis = new PipedInputStream();
   8:         ...
   9:     IclTerm uq = IclTerm.fromString(UNQUOTEDMARK);
  10:     PipedOutputStream pos = new PipedOutputStream();
  11:     PipedInputStream pis = new PipedInputStream();

View Full Code Here

PipedOutputStream

public PipedOutputStream(PipedInputStream snk)
            throws IOException
Creates a piped output stream connected to the specified piped input stream. Data bytes written to this stream will then be available as input from snk.
Parameters:
snk - The piped input stream to connect to.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of PipedOutputStream(PipedInputStream snk)
   1:      PipedInputStream pis = new PipedInputStream();
   2:      PipedOutputStream pos = new  PipedOutputStream(pis);
   3:      System.out.println("PipedInputStream");
   4:      try
   5:      { 

View Full Code Here
   1:     pis = new PipedInputStream();
   2:     pos = new PipedOutputStream(pis);
   3:     dos = new DataOutputStream(pos);
   4:     dis = new DataInputStream(pis);

View Full Code Here
   1:         PipedInputStream in = new PipedInputStream();
   2:         final PipedOutputStream out = new PipedOutputStream(in);
   3: 
   4:         Thread t = new Thread() {
   5:             public void run() {

View Full Code Here
   1:         is = new PipedInputStream();
   2:         os = new PipedOutputStream(is);
   3: 
   4:         iis = new DataInputStream(is);
   5:         ps = new PrintStream(os);

View Full Code Here
   1:    in= new PipedInputStream();
   2:    out = new PipedOutputStream(in);
   3: 
   4:   }
   5:   protected void processWindowEvent(WindowEvent e) {

View Full Code Here

Method Details

close

public void close()
            throws IOException
Closes this piped output stream and releases any system resources associated with this stream. This stream may no longer be used for writing bytes.
Specified by:
close in interface Closeable
Overrides:
close in interface OutputStream
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of close()
   1:      PipedInputStream pis = new PipedInputStream();
   2:      PipedOutputStream pos = new  PipedOutputStream(pis);
   3:      System.out.println("PipedInputStream");
   4:         ...
   5:      { 
   6:         pis.close();    
   7:         ...
   8:         pos.close();
   9:      }

View Full Code Here
   1:             PipedInputStream pin = new PipedInputStream();
   2:             PipedOutputStream pout = new PipedOutputStream();
   3:             pout.connect( pin);
   4:         ...
   5: {
   6:     PipedOutputStream pout;
   7:     File fFile;
   8:         ...
   9:         }
  10:         pout.close();
  11:     }

View Full Code Here
   1: import java.io.PipedInputStream;
   2: import java.io.PipedOutputStream;
   3: import java.io.PrintWriter;
   4:         ...
   5:         PipedInputStream in = new PipedInputStream();
   6:         final PipedOutputStream out = new PipedOutputStream(in);
   7: 
   8:         ...
   9:                     o.flush();
  10:                     o.close();
  11:                     out.flush();
  12:         ...
  13:                     out.close();

View Full Code Here
   1:   PipedInputStream in= null;
   2:   PipedOutputStream out = null;
   3: 
   4:         ...
   5:    in= new PipedInputStream();
   6:    out = new PipedOutputStream(in);
   7: 
   8:         ...
   9:   }
  10:   out.close();
  11:   }

View Full Code Here
   1: import java.io.PipedInputStream;
   2: import java.io.PipedOutputStream;
   3: public class SVNInputStream extends PipedInputStream
   4:         ...
   5:         myOutputer.closed = true;
   6:         super.close();
   7:     }
   8:         ...
   9:     {
  10:         PipedOutputStream myStream;
  11:         boolean closed;
  12:         ...
  13:         {
  14:             myStream =new PipedOutputStream(myMaster);

View Full Code Here

connect

public void connect(PipedInputStream snk)
            throws IOException
Connects this piped output stream to a receiver. If this object is already connected to some other piped input stream, an IOException is thrown.

If snk is an unconnected piped input stream and src is an unconnected piped output stream, they may be connected by either the call:

 src.connect(snk)
or the call:
 snk.connect(src)
The two calls have the same effect.
Parameters:
snk - the piped input stream to connect to.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of connect(PipedInputStream snk)
   1:             PipedInputStream pin = new PipedInputStream();
   2:             PipedOutputStream pout = new PipedOutputStream();
   3:         ...
   4:             pout.connect( pin);
   5:             new PipeSender(pout,"sendString").start();
   6:         ...
   7: {
   8:     PipedOutputStream pout;
   9:     File fFile;

View Full Code Here
   1:     IclTerm q = IclTerm.fromString(QUOTEDMARK);
   2:     PipedOutputStream pos = new PipedOutputStream();
   3:     PipedInputStream pis = new PipedInputStream();
   4:         ...
   5:     BufferedReader bpis = new BufferedReader(new InputStreamReader(pis));
   6:     pos.connect(pis);
   7:     ToWireString.getInstance().from(q, dos);
   8:         ...
   9:     IclTerm q = IclTerm.fromString(QUOTEDMARK);
  10:     PipedOutputStream pos = new PipedOutputStream();
  11:     PipedInputStream pis = new PipedInputStream();
  12:         ...
  13:     BufferedReader bpis = new BufferedReader(new InputStreamReader(pis));
  14:     pos.connect(pis);

View Full Code Here
   1:     {
   2:         PipedOutputStream pipedOutStream = new PipedOutputStream();
   3:         PipedInputStream pipedInputStream = new PipedInputStream();
   4:         ...
   5:         {
   6:             pipedOutStream.connect( pipedInputStream );
   7:             
   8:             SharedFilesPipeFiller fillerRunnable = new SharedFilesPipeFiller( pipedOutStream,
   9:                 exportOptions );

View Full Code Here
   1:     
   2:     final PipedOutputStream pos = new PipedOutputStream();
   3:     final PipedInputStream pis = new PipedInputStream();
   4:         ...
   5:     pos.connect(pis);
   6:     final DataInputStream dis = new DataInputStream(pis);
   7:     final BufferedOutputStream bos = new BufferedOutputStream(pos);

View Full Code Here
   1: class LoopedStreams {
   2:     private PipedOutputStream pipedOS = 
   3:         ...
   4:         new PipedOutputStream();
   5:     private boolean keepRunning = true;
   6:         ...
   7:     public LoopedStreams() throws IOException {
   8:         pipedOS.connect(pipedIS);
   9:         startByteArrayReaderThread();

View Full Code Here

flush

public void flush()
            throws IOException
Flushes this output stream and forces any buffered output bytes to be written out. This will notify any readers that bytes are waiting in the pipe.
Specified by:
flush in interface Flushable
Overrides:
flush in interface OutputStream
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of flush()
   1: import java.io.PipedInputStream;
   2: import java.io.PipedOutputStream;
   3: import java.io.PrintWriter;
   4:         ...
   5:         PipedInputStream in = new PipedInputStream();
   6:         final PipedOutputStream out = new PipedOutputStream(in);
   7: 
   8:         ...
   9:                     o.println(str);
  10:                     o.flush();
  11:                     o.close();
  12:         ...
  13:                     out.flush();

View Full Code Here
   1: 
   2:    private PipedOutputStream outPipe = null;
   3:    private PipedInputStream inPipe = null;
   4:         ...
   5:       super("ObjPipedMessagePassing");
   6:       outPipe = new PipedOutputStream();
   7:       try {
   8:         ...
   9:             outObj.writeObject(m);
  10:             outObj.flush();
  11:          } catch (IOException e) {

View Full Code Here
   1: 
   2:    private PipedOutputStream outPipe = null;
   3:    private PipedInputStream inPipe = null;
   4:         ...
   5:       super("ObjPipedMessagePassing");
   6:       outPipe = new PipedOutputStream();
   7:       try {
   8:         ...
   9:             outObj.writeObject(m);
  10:             outObj.flush();
  11:          } catch (IOException e) {

View Full Code Here
   1: 
   2:    private PipedOutputStream outPipe = null;
   3:    private PipedInputStream inPipe = null;
   4:         ...
   5:       super("PipedMessagePassing");
   6:       outPipe = new PipedOutputStream();
   7:       try {
   8:          inPipe = new PipedInputStream(outPipe);
   9:       } catch (IOException e) {

View Full Code Here
   1: 
   2:    private PipedOutputStream outPipe = null;
   3:    private PipedInputStream inPipe = null;
   4:         ...
   5:       super("PipedMessagePassing");
   6:       outPipe = new PipedOutputStream();
   7:       try {
   8:          inPipe = new PipedInputStream(outPipe);
   9:       } catch (IOException e) {

View Full Code Here

write

public void write(b[] ,
                  int off,
                  int len)
            throws IOException
Writes len bytes from the specified byte array starting at offset off to this piped output stream. If a thread was reading data bytes from the connected piped input stream, but the thread is no longer alive, then an IOException is thrown.
Overrides:
write in interface OutputStream
Parameters:
off - the start offset in the data.
len - the number of bytes to write.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of write(b[] ,int off,int len)
   1: 
   2:                 PipedOutputStream pos = new PipedOutputStream();
   3:                 PipedInputStream pis = new PipedInputStream(pos);
   4:         ...
   5:                 byte[] bshort = util.short2bytes(uidshort);
   6:                 pos.write(bint, 0, bint.length);
   7:         ...
   8:                 pos.write(blong, 0, blong.length);
   9:         ...
  10:                 pos.write(bshort, 0, bshort.length);

View Full Code Here
   1: class LoopedStreams {
   2:     private PipedOutputStream pipedOS = 
   3:         ...
   4:         new PipedOutputStream();
   5:     private boolean keepRunning = true;
   6:         ...
   7:                         try {
   8:                             pipedOS.write(buffer, 0, buffer.length);
   9:                         }

View Full Code Here
   1: import java.io.PipedInputStream;
   2: import java.io.PipedOutputStream;
   3: import java.io.PrintStream;
   4:         ...
   5:       if (count > 0) {
   6:         dest.write(buffer, 0, count);
   7:         total += count;
   8:         ...
   9:         sha.update(buffer, 0, count);
  10:         dest.write(buffer, 0, count);
  11:         total += count;
  12:         ...
  13:     protected boolean needStream(boolean needsData) throws IOException {
  14:       final PipedOutputStream out = new PipedOutputStream();

View Full Code Here

write

public void write(int b)
            throws IOException
Writes the specified byte to the piped output stream. If a thread was reading data bytes from the connected piped input stream, but the thread is no longer alive, then an IOException is thrown.

Implements the write method of OutputStream.

Overrides:
write in interface OutputStream
Parameters:
b - the byte to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of write(int b)
   1:      PipedInputStream pis = new PipedInputStream();
   2:      PipedOutputStream pos = new  PipedOutputStream(pis);
   3:      System.out.println("PipedInputStream");
   4:         ...
   5:      { 
   6:          pos.write(aByteData1);
   7:         ...
   8:          pos.write(aByteData2);
   9:          System.out.println((byte)pis.read());

View Full Code Here
   1: import java.io.PipedInputStream;
   2: import java.io.PipedOutputStream;
   3: public class SVNInputStream extends PipedInputStream
   4:         ...
   5:     {
   6:         PipedOutputStream myStream;
   7:         boolean closed;
   8:         ...
   9:         {
  10:             myStream =new PipedOutputStream(myMaster);
  11:         }
  12:         ...
  13:                 throw new IOException("stream has been closed");
  14:             myStream.write(data);

View Full Code Here
   1:     private PipedInputStream pis;
   2:     private PipedOutputStream pos;
   3: 
   4:         ...
   5:         pis = new PipedInputStream();
   6:         pos = new PipedOutputStream();
   7:         try {
   8:         ...
   9:             int magic2 = in.read();
  10:             pos.write(magic1);
  11:         ...
  12:             pos.write(magic2);

View Full Code Here
   1: import java.io.PipedInputStream;
   2: import java.io.PipedOutputStream;
   3: import java.io.Reader;
   4:         ...
   5:                if (bt == 0) break;
   6:                out.write(bt);
   7:             }
   8:         ...
   9:             PipedInputStream in = new PipedInputStream();
  10:             PipedOutputStream out = new PipedOutputStream(in);
  11:         ...
  12:             out.write(raw);

View Full Code Here
   1:                 try {
   2:                         PipedOutputStream pos = new PipedOutputStream();
   3:                         PipedInputStream pis = new PipedInputStream(pos);
   4:         ...
   5:                         pos.write(in.getBytes(), 0, in.length());
   6:                         pos.flush();
   7:                         pos.close();
   8:                         return new DataInputStream(pis);

View Full Code Here