|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.InputStream | +--com.caucho.vfs.ReadStream
A fast bufferered input stream supporting both character and byte data. The underlying stream sources are provided by StreamImpl classes, so all streams have the same API regardless of the underlying implementation.
Dynamic streams, like tcp and http will properly flush writes before reading input. And random access streams, like RandomAccessFile, can use the same API as normal streams.
Most applications will use the Path routines to create their own streams. Specialized applications, like servers, need the capability of recycling streams.
Constructor Summary | |
ReadStream()
Creates an uninitialized stream. |
|
ReadStream(StreamImpl source)
Creates a stream and initializes with a specified source. |
|
ReadStream(StreamImpl source,
WriteStream sibling)
Creates a stream and initializes with a specified source. |
Method Summary | |
int |
available()
Compatibility with InputStream. |
boolean |
canRead()
Returns true if the stream allows reading. |
void |
clearRead()
Clears the read buffer. |
void |
close()
Close the stream. |
int |
fillBuffer()
|
java.lang.Object |
getAttribute(java.lang.String name)
Returns a named attribute. |
java.util.Iterator |
getAttributeNames()
Lists all named attributes. |
int |
getAvailable()
Returns an estimate of the available bytes. |
byte[] |
getBuffer()
|
java.lang.String |
getEncoding()
Returns the mime-encoding currently read. |
int |
getLength()
|
int |
getOffset()
|
Path |
getPath()
Returns the Path which opened this stream. |
long |
getPosition()
Returns the current read position. |
java.io.Reader |
getReader()
Returns a Reader reading to this stream. |
WriteStream |
getSibling()
|
StreamImpl |
getSource()
Returns the underlying source for the stream. |
java.lang.String |
getUserPath()
Returns the user path which opened this stream. |
void |
init(StreamImpl source,
WriteStream sibling)
Initializes the stream with a given source. |
void |
pushFilter(StreamFilter filter)
Pushes a filter on the top of the stream stack. |
int |
read()
Returns the next byte or -1 if at the end of file. |
int |
read(byte[] buf,
int offset,
int length)
Reads into a byte array. |
int |
read(char[] buf,
int offset,
int length)
Reads into a character buffer from the stream. |
int |
read(CharBuffer buf,
int length)
Reads characters from the stream, appending to the character buffer. |
int |
readAll(byte[] buf,
int offset,
int length)
Reads into a byte array. |
int |
readAll(char[] buf,
int offset,
int length)
Reads into a character buffer from the stream. |
int |
readAll(CharBuffer buf,
int length)
Reads characters from the stream, appending to the character buffer. |
int |
readChar()
Reads a character from the stream, returning -1 on end of file. |
java.lang.String |
readLine()
Reads a line, returning a string. |
int |
readLine(char[] buf,
int length)
Reads a line into the character buffer. |
boolean |
readLine(CharBuffer cb)
Reads a line into the character buffer. |
java.lang.String |
readln()
|
boolean |
readln(CharBuffer cb)
|
void |
removeAttribute(java.lang.String name)
Removes a named attribute. |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets a named attribute. |
void |
setDisableClose(boolean disableClose)
Disables close. |
void |
setEncoding(java.lang.String encoding)
Sets the current read encoding. |
void |
setOffset(int offset)
|
void |
setPath(Path path)
Sets a path name associated with the stream. |
void |
setPosition(int pos)
Returns the sets current read position. |
void |
setReuseBuffer(boolean reuse)
|
void |
setSibling(WriteStream sibling)
|
long |
skip(long n)
Skips the next n bytes. |
java.lang.String |
toString()
Returns a printable representation of the read stream. |
void |
unread()
Unreads the last byte. |
void |
writeToStream(java.io.OutputStream os)
Copies this stream to the output stream. |
void |
writeToStream(java.io.OutputStream os,
int len)
Writes len |
void |
writeToWriter(java.io.Writer out)
Copies this stream to the output stream. |
Methods inherited from class java.io.InputStream |
mark, markSupported, read, reset |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ReadStream()
init
to initialize.public ReadStream(StreamImpl source)
source
- Underlying source for the stream.public ReadStream(StreamImpl source, WriteStream sibling)
source
- Underlying source for the stream.sibling
- Sibling write stream.Method Detail |
public void init(StreamImpl source, WriteStream sibling)
source
- Underlying source for the stream.sibling
- Sibling write streampublic void setSibling(WriteStream sibling)
public WriteStream getSibling()
public StreamImpl getSource()
public void setReuseBuffer(boolean reuse)
public void pushFilter(StreamFilter filter)
filter
- the filter to be added.public byte[] getBuffer()
public int getOffset()
public int getLength()
public void setOffset(int offset)
public boolean canRead()
public void clearRead()
public int getAvailable() throws java.io.IOException
public int available() throws java.io.IOException
available
in class java.io.InputStream
public long getPosition()
public void setPosition(int pos)
Note: currently unavailable
public final int read() throws java.io.IOException
read
in class java.io.InputStream
public final void unread()
public long skip(long n) throws java.io.IOException
n
bytes.skip
in class java.io.InputStream
n
- bytes to skip.public final int read(byte[] buf, int offset, int length) throws java.io.IOException
read
may return less than
the maximum bytes even if more bytes are available to read.read
in class java.io.InputStream
buf
- byte arrayoffset
- offset into the byte array to start readinglength
- maximum byte allowed to read.public int readAll(byte[] buf, int offset, int length) throws java.io.IOException
readAll
will always read
length
bytes, blocking if necessary, until the end of
file is reached.buf
- byte arrayoffset
- offset into the byte array to start readinglength
- maximum byte allowed to read.public void setEncoding(java.lang.String encoding) throws java.io.UnsupportedEncodingException
encoding
- name of the read encodingpublic java.lang.String getEncoding()
public final int readChar() throws java.io.IOException
public final int read(char[] buf, int offset, int length) throws java.io.IOException
buf
- character buffer to filloffset
- starting offset into the character bufferlength
- maximum number of characters to readpublic int readAll(char[] buf, int offset, int length) throws java.io.IOException
length
characters will always be read until the end of file is reached.buf
- character buffer to filloffset
- starting offset into the character bufferlength
- maximum number of characters to readpublic int read(CharBuffer buf, int length) throws java.io.IOException
buf
- character buffer to filllength
- maximum number of characters to readpublic int readAll(CharBuffer buf, int length) throws java.io.IOException
length
characters will always be read until the end of
file.buf
- character buffer to filllength
- maximum number of characters to readpublic final boolean readln(CharBuffer cb) throws java.io.IOException
public final boolean readLine(CharBuffer cb) throws java.io.IOException
buf
- character buffer to fillpublic final int readLine(char[] buf, int length) throws java.io.IOException
buf
- character buffer to fillpublic final java.lang.String readln() throws java.io.IOException
public java.lang.String readLine() throws java.io.IOException
public void writeToStream(java.io.OutputStream os) throws java.io.IOException
os
- destination stream.public void writeToStream(java.io.OutputStream os, int len) throws java.io.IOException
len bytes to the output stream from this stream.
- Parameters:
os
- destination stream.len
- bytes to write.
public void writeToWriter(java.io.Writer out) throws java.io.IOException
out
- destination writerpublic int fillBuffer() throws java.io.IOException
public void setDisableClose(boolean disableClose)
public final void close() throws java.io.IOException
close
in class java.io.InputStream
public java.lang.Object getAttribute(java.lang.String name) throws java.io.IOException
public java.util.Iterator getAttributeNames() throws java.io.IOException
public void setAttribute(java.lang.String name, java.lang.Object value) throws java.io.IOException
public void removeAttribute(java.lang.String name) throws java.io.IOException
public Path getPath()
public java.lang.String getUserPath()
Parsing routines typically use this for error reporting.
public void setPath(Path path)
public java.io.Reader getReader()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |