Class ccj.TextInputStream
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ccj.TextInputStream

java.lang.Object
   |
   +----java.io.InputStream
           |
           +----ccj.TextInputStream

public class TextInputStream
extends InputStream

Constructor Index

 o TextInputStream(String)
Constructs a text input stream that reads its input from a file

Method Index

 o close()
Closes the input stream
 o fail()
Tests if the output stream is no longer valid
 o read()
Reads one character from the input stream.
 o readChar()
Reads the next character from the stream.
 o readDouble()
Reads a floating-point number from the stream.
 o readInt()
Reads an integer (in decimal) from the stream.
 o readLine()
Reads a line from the stream
 o readWord()
Reads a word from the stream.
 o unread(int)
Returns one character to the input stream, to be read again

Constructors

 o TextInputStream
  public TextInputStream(String s)
Constructs a text input stream that reads its input from a file
Parameters:
s - the file name

Methods

 o readLine
  public String readLine()
Reads a line from the stream
Returns:
the line, without the terminating newline. If a blank line is read, the empty string is returned. If the end of input has been reached an no character has been read, the empty string is returned and the stream is set to a failed state.
 o readWord
  public String readWord()
Reads a word from the stream. A word is a string delimited by white space.
Returns:
the line, without the surrounding white space. If the end of input has been reached an no character has been read, the empty string is returned and the stream is set to a failed state.
 o readChar
  public String readChar()
Reads the next character from the stream.
Returns:
the character, as a one-character string. If the end of input has been reached an no character has been read, the empty string is returned and the stream is set to a failed state.
 o readInt
  public int readInt()
Reads an integer (in decimal) from the stream.
Returns:
the integer value. If the input is not a valid integer, the number zero is returned and the stream is set to a failed state.
 o readDouble
  public double readDouble()
Reads a floating-point number from the stream.
Returns:
the floating-point value. If the input is not a valid floating-point number, the number zero is returned and the stream is set to a failed state.
 o fail
  public boolean fail()
Tests if the output stream is no longer valid
Returns:
true if the stream has failed
 o read
  public int read()
Reads one character from the input stream.
Returns:
the character read, or -1 at the end of input.
Overrides:
read in class InputStream
 o unread
  public void unread(int x)
Returns one character to the input stream, to be read again
Parameters:
x - the character to be pushed back
 o close
  public void close()
Closes the input stream
Overrides:
close in class InputStream

All Packages  Class Hierarchy  This Package  Previous  Next  Index