    All Packages    This Package    Previous    Next

# Class java.io.PushbackInputStream

    java.lang.Object
       |
       +----java.io.InputStream
               |
               +----java.io.FilterInputStream
                       |
                       +----java.io.PushbackInputStream

public class PushbackInputStream
extends FilterInputStream

An input stream that has a 1 byte push back buffer. It also keeps track of line numbers.

Version:
  1.6, 31 Jan 1995
Author:
  Jonathan Payne

##

lineNumber
  The current line number.
pushBack
  Push back character.

##

PushbackInputStream(InputStream)
  Creates a PushbackInputStream.

##

currentLine()
  Returns the current line number.
read()
  Reads a byte.
read(byte[], int, int)
  Reads into an array of bytes.
unread(int)
  Pushes back a character.

##

pushBack

      protected int pushBack

  Push back character.

lineNumber

      protected int lineNumber

  The current line number.

##

PushbackInputStream

      public PushbackInputStream(InputStream in)

  Creates a PushbackInputStream.
  Parameters:
    in - the input stream

##

read

      public int read()

  Reads a byte. Will block if no input is available.
  Returns:
    the byte read, or -1 if the end of the stream is reached.
  Throws: IOException
    i/o error occurred
  Overrides:
    read in class FilterInputStream

read

      public int read(byte bytes[],
                      int offset,
                      int length)

  Reads into an array of bytes. Blocks until some input is available. This method should be overridden in a subclass for efficiency (the default implementation reads 1 byte at a time).
  Parameters:
    b - the buffer into which the data is read
    off - the start offset of the data
    len - the maximum number of bytes read
  Returns:
    the actual number of bytes read, -1 is returned when the end of the stream is reached.
  Throws: IOException
    i/o error occurred
  Overrides:
    read in class FilterInputStream

unread

      public void unread(int ch)

  Pushes back a character.
  Parameters:
    ch - the character to push back.
  Throws: Exception
    Attempt to push back more than one character.

currentLine

      public int currentLine()

  Returns the current line number.

    All Packages    This Package    Previous    Next