info1
Class TextInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byinfo1.TextInputStream

public class TextInputStream
extends java.io.InputStream


Constructor Summary
TextInputStream(java.lang.String s)
          Constructs a text input stream that reads its input from a file
 
Method Summary
 void close()
          Closes the input stream
 boolean fail()
          Tests if the output stream is no longer valid
 int read()
          Reads one character from the input stream.
 java.lang.String readChar()
          Reads the next character from the stream.
 double readDouble()
          Reads a floating-point number from the stream.
 int readInt()
          Reads an integer (in decimal) from the stream.
 java.lang.String readLine()
          Reads a line from the stream
 java.lang.String readWord()
          Reads a word from the stream.
 void unread(int x)
          Returns one character to the input stream, to be read again
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextInputStream

public TextInputStream(java.lang.String s)
Constructs a text input stream that reads its input from a file

Parameters:
s - the file name
Method Detail

readLine

public java.lang.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.

readWord

public java.lang.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.

readChar

public java.lang.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.

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.

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.

fail

public boolean fail()
Tests if the output stream is no longer valid

Returns:
true if the stream has failed

read

public int read()
Reads one character from the input stream.

Returns:
the character read, or -1 at the end of input.

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

close

public void close()
Closes the input stream