java.io

Class PipedWriter

Implemented Interfaces:
Appendable, Closeable, Flushable

public class PipedWriter
extends Writer

Piped character-output streams.
Since:
JDK1.1

Field Summary

Fields inherited from class java.io.Writer

lock

Constructor Summary

PipedWriter()
Creates a piped writer that is not yet connected to a piped reader.
PipedWriter(PipedReader snk)
Creates a piped writer connected to the specified piped reader.

Method Summary

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

Methods inherited from class java.io.Writer

append, append, append, close, flush, write, write, 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

PipedWriter

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

View More Examples of PipedWriter()
   1:         pipedReader = new PipedReader();
   2:         pipedWriter = new PipedWriter();
   3:         pipedWriter.connect(pipedReader);
   4:     }
   5:     

View Full Code Here
   1: 
   2:         PipedWriter pipeOut = new PipedWriter();
   3:         PipedReader pipeIn = new PipedReader(pipeOut);
   4:         ...
   5: 
   6:         PipedWriter pipeOut = new PipedWriter();
   7:         PipedReader pipeIn = new PipedReader(pipeOut);
   8:         PrintWriter out = new PrintWriter(pipeOut);

View Full Code Here
   1:   private Random rand = new Random(47);
   2:   private PipedWriter out = new PipedWriter();
   3:   public PipedWriter getPipedWriter() { return out; }
   4:   public void run() {
   5:     try {

View Full Code Here
   1:         out = new ConsoleBuffer(DEFAULT_LINE_BUFFER_SIZE);
   2:         pipe = new PipedWriter();
   3:         in = new PipedReader();
   4:         try {
   5:             pipe.connect(in);

View Full Code Here

PipedWriter

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

View More Examples of PipedWriter(PipedReader snk)
   1:     PrintWriter getWriter(  ) throws IOException {
   2:         return new PrintWriter( new PipedWriter( in ) );
   3:     }
   4: }

View Full Code Here
   1:         PipedReader in = new PipedReader();
   2:         PipedWriter pout = new PipedWriter(in);
   3:         PrintWriter out = new PrintWriter(pout, true);
   4:         out.close();
   5:         pout.close();

View Full Code Here
   1:     {
   2:         m_writer = new BufferedWriter(new PipedWriter(m_reader));
   3:         String line = br.readLine();
   4: 
   5:         write("<?xml version=\"1.0\"?>\n");

View Full Code Here
   1: 
   2:                     w = new PipedWriter((PipedReader) r);  
   3:                    closeWriterAfterUse = true;
   4: 
   5:                     thread.start();

View Full Code Here
   1:         try {
   2:         pout = new PrintWriter(new PipedWriter(pin), true);
   3:         throw new InternalSpaceException("PipedReader closed?", e);
   4:         }
   5:         connect(new InputStreamReader(proc.getInputStream()),

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 characters.
Specified by:
close in interface Closeable
Overrides:
close in interface Writer
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of close()
   1: import java.io.PipedReader;
   2: import java.io.PipedWriter;
   3: import java.io.PrintWriter;
   4:         ...
   5:         PipedReader in = new PipedReader();
   6:         PipedWriter pout = new PipedWriter(in);
   7:         PrintWriter out = new PrintWriter(pout, true);
   8:         ...
   9:         out.close();
  10:         ...
  11:         pout.close();

View Full Code Here

connect

public void connect(PipedReader snk)
            throws IOException
Connects this piped writer to a receiver. If this object is already connected to some other piped reader, an IOException is thrown.

If snk is an unconnected piped reader and src is an unconnected piped writer, 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 reader to connect to.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of connect(PipedReader snk)
   1: import java.io.PipedReader;
   2: import java.io.PipedWriter;
   3: 
   4:         ...
   5:     PipedReader pipedReader;
   6:     PipedWriter pipedWriter;
   7: 
   8:         ...
   9:         pipedWriter = new PipedWriter();
  10:         pipedWriter.connect(pipedReader);
  11:     }

View Full Code Here
   1: import java.io.PipedReader;
   2: import java.io.PipedWriter;
   3: import java.io.Reader;
   4:         ...
   5:     private PipedReader in;
   6:     private PipedWriter pipe;
   7:     protected ConsoleUI ui;
   8:         ...
   9:         out = new ConsoleBuffer(DEFAULT_LINE_BUFFER_SIZE);
  10:         pipe = new PipedWriter();
  11:         in = new PipedReader();
  12:         ...
  13:         try {
  14:             pipe.connect(in);

View Full Code Here

flush

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

View More Examples of flush()
   1: import java.io.PipedReader;
   2: import java.io.PipedWriter;
   3: 
   4:         ...
   5:     PipedReader pipedReader;
   6:     PipedWriter pipedWriter;
   7: 
   8:         ...
   9:         pipedWriter.write(s);
  10:         pipedWriter.flush();
  11:     }
  12:         ...
  13:         pipedWriter.write(s + "\n");
  14:         pipedWriter.flush();

View Full Code Here
   1: import java.io.PipedReader;
   2: import java.io.PipedWriter;
   3: import java.io.Reader;
   4:         ...
   5:     private PipedReader in;
   6:     private PipedWriter pipe;
   7:     protected ConsoleUI ui;
   8:         ...
   9:         out = new ConsoleBuffer(DEFAULT_LINE_BUFFER_SIZE);
  10:         pipe = new PipedWriter();
  11:         in = new PipedReader();
  12:         ...
  13:         pipe.write("\n");
  14:         pipe.flush();

View Full Code Here
   1: import java.io.PipedReader;
   2: import java.io.PipedWriter;
   3: import java.io.PrintStream;
   4:         ...
   5:    {
   6:       PipedWriter pw;
   7:       PipedReader pr = null;
   8:         ...
   9:       pw = new PipedWriter();
  10:       pr = new PipedReader(pw);
  11:         ...
  12:       pstream.println(str);
  13:       pstream.flush();

View Full Code Here

write

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

View More Examples of write(cbuf[] ,int off,int len)
   1: import java.io.PipedReader;
   2: import java.io.PipedWriter;
   3: import java.io.Reader;
   4:         ...
   5:     private PipedReader in;
   6:     private PipedWriter pipe;
   7:     protected ConsoleUI ui;
   8:         ...
   9:         out = new ConsoleBuffer(DEFAULT_LINE_BUFFER_SIZE);
  10:         pipe = new PipedWriter();
  11:         in = new PipedReader();
  12:         ...
  13:     public void enter(char[] cbuf, int offset, int size) throws IOException {
  14:         pipe.write(cbuf, offset, size);

View Full Code Here

write

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

Implements the write method of Writer.

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

View More Examples of write(int c)
   1: import java.io.PipedReader;
   2: import java.io.PipedWriter;
   3: 
   4:         ...
   5:     PipedReader pipedReader;
   6:     PipedWriter pipedWriter;
   7: 
   8:         ...
   9:     public void write(String s) throws IOException {
  10:         pipedWriter.write(s);
  11:         pipedWriter.flush();
  12:         ...
  13:     public void writeln(String s) throws IOException {
  14:         pipedWriter.write(s + "\n");

View Full Code Here
   1:   private Random rand = new Random(47);
   2:   private PipedWriter out = new PipedWriter();
   3:         ...
   4:   public PipedWriter getPipedWriter() { return out; }
   5:   public void run() {
   6:         ...
   7:         for(char c = 'A'; c <= 'z'; c++) {
   8:           out.write(c);
   9:           TimeUnit.MILLISECONDS.sleep(rand.nextInt(500));

View Full Code Here
   1: import java.io.PipedReader;
   2: import java.io.PipedWriter;
   3: import java.io.Reader;
   4:         ...
   5:     private PipedReader in;
   6:     private PipedWriter pipe;
   7:     protected ConsoleUI ui;
   8:         ...
   9:         out = new ConsoleBuffer(DEFAULT_LINE_BUFFER_SIZE);
  10:         pipe = new PipedWriter();
  11:         in = new PipedReader();
  12:         ...
  13:         pipe.write(cbuf, offset, size);
  14:         pipe.write("\n");

View Full Code Here
   1:           i++;
   2:           vystup.write(c);
   3:           stav.setText("Odesilatel odeslal: " 
   4:         ...
   5:   private Blokovany[] blokovane;
   6:   private PipedWriter vystup;
   7:   private PipedReader vstup;
   8:         ...
   9:      kontejner.setLayout(new FlowLayout());
  10:      vystup = new PipedWriter();
  11:     try {

View Full Code Here
   1: import java.io.PipedReader;
   2: import java.io.PipedWriter;
   3: import java.util.StringTokenizer;
   4:         ...
   5:         try {
   6:             PipedWriter pw = new PipedWriter();
   7:             PipedReader pr = new PipedReader(pw);
   8:         ...
   9:                 System.err.println("hand.getRawCardsBuffered()="+hand.getRawCardsBuffered());
  10:                 pw.write(hand.getRawCardsBuffered() + "\n");
  11:                 game.nextHand(br);

View Full Code Here