java.io
Class PipedReader
- Closeable, Readable
An input stream that reads characters from a piped writer to which it is
connected.
Data is read and written to an internal buffer. It is highly recommended
that the
PipedReader
and connected
PipedWriter
be part of different threads. If they are not, there is a possibility
that the read and write operations could deadlock their thread.
PipedReader() - Creates a new
PipedReader that is not connected to a
PipedWriter .
|
PipedReader(PipedWriter source) - This constructor creates a new
PipedReader and connects
it to the passed in PipedWriter .
|
void | close() - This methods closes the stream so that no more data can be read
from it.
|
void | connect(PipedWriter source) - This method connects this stream to the passed in
PipedWriter .
|
int | read() - This method reads chars from the stream into a caller supplied buffer.
|
int | read(char[] buf, int offset, int len) - This method reads characters from the stream into a caller supplied
buffer.
|
boolean | ready() - Determines whether or not this stream is ready to be
read.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
PipedReader
public PipedReader()
Creates a new PipedReader
that is not connected to a
PipedWriter
. It must be connected before chars can
be read from this stream.
PipedReader
public PipedReader(PipedWriter source)
throws IOException
This constructor creates a new PipedReader
and connects
it to the passed in PipedWriter
. The stream is then
ready for reading.
source
- The PipedWriter
to connect this stream to
connect
public void connect(PipedWriter source)
throws IOException
This method connects this stream to the passed in
PipedWriter
.
This stream is then ready for reading. If this stream is already
connected or has been previously closed, then an exception is thrown
source
- The PipedWriter
to connect this stream to
IOException
- If this PipedReader or source
has been connected already.
read
public int read()
throws IOException
This method reads chars from the stream into a caller supplied buffer.
It starts storing chars at position
offset
into the
buffer and
reads a maximum of
len
chars. Note that this method
can actually
read fewer than
len
chars. The actual number of chars
read is
returned. A -1 is returned to indicated that no chars can be read
because the end of the stream was reached. If the stream is already
closed, a -1 will again be returned to indicate the end of the stream.
This method will block if no char is available to be read.
- read in interface Reader
read
public int read(char[] buf,
int offset,
int len)
throws IOException
This method reads characters from the stream into a caller supplied
buffer. It starts storing chars at position
offset
into
the buffer and reads a maximum of
len
chars. Note that
this method can actually read fewer than
len
chars.
The actual number of chars read is
returned. A -1 is returned to indicated that no chars can be read
because the end of the stream was reached - ie close() was called on the
connected PipedWriter.
This method will block if no chars are available to be read.
buf
- The buffer into which chars will be storedoffset
- The index into the buffer at which to start writing.len
- The maximum number of chars to read.
IOException
- If close()
was called on this Piped
Reader.
ready
public boolean ready()
throws IOException
Determines whether or not this stream is ready to be
read. If it returns
false
the stream may block if a
read is attempted, but it is not guaranteed to do so.
This method always returns
false
in this class
- ready in interface Reader
true
if the stream is ready to be read,
false
otherwise.
PipedReader.java -- Read portion of piped character streams.
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.