ASCIIReaderpublic class ASCIIReader extends Reader A simple ASCII byte reader. This is an optimized reader for reading
byte streams that only contain 7-bit ASCII characters. |
Fields Summary |
---|
public static final int | DEFAULT_BUFFER_SIZEDefault byte buffer size (2048). | protected InputStream | fInputStreamInput stream. | protected byte[] | fBufferByte buffer. |
Constructors Summary |
---|
public ASCIIReader(InputStream inputStream, int size)Constructs an ASCII reader from the specified input stream
and buffer size.
//
// Constructors
//
fInputStream = inputStream;
fBuffer = new byte[size];
|
Methods Summary |
---|
public void | close()Close the stream. Once a stream has been closed, further read(),
ready(), mark(), or reset() invocations will throw an IOException.
Closing a previously-closed stream, however, has no effect.
fInputStream.close();
| public void | mark(int readAheadLimit)Mark the present position in the stream. Subsequent calls to reset()
will attempt to reposition the stream to this point. Not all
character-input streams support the mark() operation.
fInputStream.mark(readAheadLimit);
| public boolean | markSupported()Tell whether this stream supports the mark() operation.
return fInputStream.markSupported();
| public int | read()Read a single character. This method will block until a character is
available, an I/O error occurs, or the end of the stream is reached.
Subclasses that intend to support efficient single-character input
should override this method.
int b0 = fInputStream.read();
if (b0 > 0x80) {
throw new IOException(Localizer.getMessage("jsp.error.xml.invalidASCII",
Integer.toString(b0)));
}
return b0;
| public int | read(char[] ch, int offset, int length)Read characters into a portion of an array. This method will block
until some input is available, an I/O error occurs, or the end of the
stream is reached.
if (length > fBuffer.length) {
length = fBuffer.length;
}
int count = fInputStream.read(fBuffer, 0, length);
for (int i = 0; i < count; i++) {
int b0 = fBuffer[i];
if (b0 < 0) {
throw new IOException(Localizer.getMessage("jsp.error.xml.invalidASCII",
Integer.toString(b0)));
}
ch[offset + i] = (char)b0;
}
return count;
| public boolean | ready()Tell whether this stream is ready to be read.
return false;
| public void | reset()Reset the stream. If the stream has been marked, then attempt to
reposition it at the mark. If the stream has not been marked, then
attempt to reset it in some way appropriate to the particular stream,
for example by repositioning it to its starting point. Not all
character-input streams support the reset() operation, and some support
reset() without supporting mark().
fInputStream.reset();
| public long | skip(long n)Skip characters. This method will block until some characters are
available, an I/O error occurs, or the end of the stream is reached.
return fInputStream.skip(n);
|
|