Class: java.io.CharArrayReader

  • public class CharArrayReader
  • extends Reader
This class implements a character buffer that can be used as a character-input stream.
Authors:
@author Herb Jellinek
Since:
@since JDK1.1

Inheritance

Superclass tree: Implements:

Methods

  • CharArrayReadertop

    public CharArrayReader(char[] buf)
    Creates a CharArrayReader from the specified array of chars.
    Parameters:
    @param buf Input buffer (not copied)
    Google Code Search
    Stack Overflow
  • CharArrayReadertop

    public CharArrayReader(char[] buf, int offset, int length)
    Creates a CharArrayReader from the specified array of chars.

    The resulting reader will start reading at the given offset. The total number of char values that can be read from this reader will be either length or buf.length-offset, whichever is smaller.

    Parameters:
    @param buf Input buffer (not copied)
    @param offset Offset of the first char to read
    @param length Number of chars to read
    Exceptions:
    @throws IllegalArgumentException If offset is negative or greater than buf.length, or if length is negative, or if the sum of these two values is negative.
    Google Code Search
    Stack Overflow
  • closetop

    public void close()
    Closes the stream and releases any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.
    Specified by:
    close from Closeable
    Override hierarchy:
    close from Reader
    Google Code Search
    Stack Overflow
  • marktop

    public void mark(int readAheadLimit) throws IOException
    Marks the present position in the stream. Subsequent calls to reset() will reposition the stream to this point.
    Parameters:
    @param readAheadLimit Limit on the number of characters that may be read while still preserving the mark. Because the stream's input comes from a character array, there is no actual limit; hence this argument is ignored.
    Exceptions:
    @exception IOException If an I/O error occurs
    Override hierarchy:
    mark from Reader
    Google Code Search
    Stack Overflow
  • markSupportedtop

    public boolean markSupported()
    Tells whether this stream supports the mark() operation, which it does.
    Return:
    @return true if and only if this stream supports the mark operation.
    Override hierarchy:
    markSupported from Reader
    Google Code Search
    Stack Overflow
  • readtop

    public int read() throws IOException
    Reads a single character.
    Return:
    @return The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached
    Exceptions:
    @exception IOException If an I/O error occurs
    Override hierarchy:
    read from Reader
    Google Code Search
    Stack Overflow
  • readtop

    public int read(char[] b, int off, int len) throws IOException
    Reads characters into a portion of an array.
    Parameters:
    @param b Destination buffer
    @param off Offset at which to start storing characters
    @param len Maximum number of characters to read
    Return:
    @return The actual number of characters read, or -1 if the end of the stream has been reached
    Exceptions:
    @exception IOException If an I/O error occurs
    Override hierarchy:
    read from Reader
    Google Code Search
    Stack Overflow
  • readytop

    public boolean ready() throws IOException
    Tells whether this stream is ready to be read. Character-array readers are always ready to be read.
    Return:
    @return True if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.
    Exceptions:
    @exception IOException If an I/O error occurs
    Override hierarchy:
    ready from Reader
    Google Code Search
    Stack Overflow
  • resettop

    public void reset() throws IOException
    Resets the stream to the most recent mark, or to the beginning if it has never been marked.
    Exceptions:
    @exception IOException If an I/O error occurs
    Override hierarchy:
    reset from Reader
    Google Code Search
    Stack Overflow
  • skiptop

    public long skip(long n) throws IOException
    Skips characters. Returns the number of characters that were skipped.

    The n parameter may be negative, even though the skip method of the java.io.Reader superclass throws an exception in this case. If n is negative, then this method does nothing and returns 0.

    Parameters:
    @param n The number of characters to skip
    Return:
    @return The number of characters actually skipped
    Exceptions:
    @exception IOException If the stream is closed, or an I/O error occurs
    Override hierarchy:
    skip from Reader
    Google Code Search
    Stack Overflow

Fields

  • buf

    protected char[] buf
    The character buffer.
  • count

    protected int count
    The index of the end of this buffer. There is not valid data at or beyond this index.
  • markedPos

    protected int markedPos
    The position of mark in buffer.
  • pos

    protected int pos
    The current buffer position.