All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class structure.ReadStream

java.lang.Object
    |
    +----java.io.InputStream
            |
            +----java.io.FilterInputStream
                    |
                    +----structure.ReadStream

public class ReadStream
extends FilterInputStream
A ReadStream provides reasonable access to the typewritten data on an input stream. Usually, a ReadStream is constructed with no parameters, causing the ReadStream to open access to System.in.

The access methods allow one to read from the stream, much as is done with Pascal.


Constructor Index

 o ReadStream()
Construct an empty ReadStream, obtaining info from System.in.
 o ReadStream(InputStream)
Construct a ReadStream based on pre-existing input stream.

Method Index

 o eof()
Determine if we've seen end-of-file.
 o eoln()
Return true if the next character to be read is an end-of-line mark.
 o peek()
Read (but don't consume) next char in stream.
 o pushbackChar(char)
Return character to input stream for reading at later time.
 o readBoolean()
Read the next word "true" or "false" as a boolean.
 o readChar()
Read next character, whitespace or not.
 o readDouble()
Reads the next double value from input stream.
 o readFloat()
Read floating point value from input (Currently not working).
 o readFully(byte[])
Read an array of bytes from input.
 o readFully(byte[], int, int)
Read input into byte array.
 o readInt()
Reads an integer from input stream.
 o readLine()
Read the remainder of line, including end-of-line mark.
 o readln()
Read characters up to and including the end-of-line mark.
 o readLong()
Read a (potentially long) input.
 o readShort()
Reads an integer from input stream.
 o readString()
Skip white space and read in the next non-whitespace word as a string.
 o readUTF()
Read unicode from input.
 o skipWhite()
Consume all the white-space characters until EOF or other data.

Constructors

 o ReadStream
public ReadStream()
Construct an empty ReadStream, obtaining info from System.in.

Postcondition:
constructs a pascal-like stream based on System.in

 o ReadStream
public ReadStream(InputStream strm)
Construct a ReadStream based on pre-existing input stream.

Precondition:
strm is a valid input stream.
Postcondition:
constructs a pascal-like stream based on strm

Parameters:
strm - The pre-existing input stream.

Methods

 o eof
public boolean eof()
Determine if we've seen end-of-file.

Precondition:
are we at the end-of-file?

Returns:
True if the next character to be read is EOF.
 o peek
public char peek()
Read (but don't consume) next char in stream.
Postcondition:
returns next character in stream, without consuming it

Returns:
The next character to be read.
 o eoln
public boolean eoln()
Return true if the next character to be read is an end-of-line mark.

Postcondition:
returns true if next stream char is a eoln char

Returns:
True iff the next character is an end-of-line mark.
 o readln
public void readln()
Read characters up to and including the end-of-line mark.

Postcondition:
reads input stream until end-of-line (\r or \n)

 o skipWhite
public void skipWhite()
Consume all the white-space characters until EOF or other data.

Postcondition:
input pointer is at EOF, or non-whitespace char.

 o readString
public String readString()
Skip white space and read in the next non-whitespace word as a string.

Postcondition:
reads next word as a string

Returns:
The next word on the input.
 o readBoolean
public boolean readBoolean()
Read the next word "true" or "false" as a boolean.

Postcondition:
returns next boolean value read from input

Returns:
The value true or false, depending on input.
 o readChar
public char readChar()
Read next character, whitespace or not. Fail on eof.

Postcondition:
returns next character, or 0 for eof

Returns:
The next character, or the value 0 indicating EOF.
 o pushbackChar
public void pushbackChar(char c)
Return character to input stream for reading at later time.

Postcondition:
pushes back character, possibly clearing EOF. if c == 0, does nothing

Parameters:
c - The character to push back onto input stream.
 o readDouble
public double readDouble()
Reads the next double value from input stream. Whitespace is skipped beforehand. CURRENTLY NOT WORKING.

Postcondition:
reads in double value

Returns:
The next double found on input.
 o readFloat
public float readFloat()
Read floating point value from input (Currently not working). Skips whitespace before reading.

Postcondition:
reads floating point value and returns value

Returns:
Next floating point number.
 o readFully
public void readFully(byte[] b) throws IOException
Read an array of bytes from input.

Parameters:
b - The array of bytes; holds result.
 o readFully
public void readFully(byte[] b,
                      int off,
                      int len) throws IOException
Read input into byte array.

Parameters:
b - Target array of bytes.
off - Offset into byte array to start reading.
len - Number of bytes to be read.
 o readShort
public short readShort()
Reads an integer from input stream.

Postcondition:
reads a short integer from stream

Returns:
The integer read form input.
 o readInt
public int readInt()
Reads an integer from input stream.

Postcondition:
reads an integer from stream

Returns:
The integer read form input.
 o readLong
public long readLong()
Read a (potentially long) input.
Postcondition:
reads a long integer from stream

Returns:
The integer read from input.
 o readLine
public String readLine()
Read the remainder of line, including end-of-line mark.

Postcondition:
reads remainder of line, returns as string

Returns:
The string containing all the characters to end-of-line.
 o readUTF
public String readUTF() throws IOException
Read unicode from input.

Returns:
String version of UTF character.

All Packages  Class Hierarchy  This Package  Previous  Next  Index