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
-
TextInputStream(String)
- Constructs a text input stream that reads its input from a file
-
close()
- Closes the input stream
-
fail()
- Tests if the output stream is no longer valid
-
read()
- Reads one character from the input stream.
-
readChar()
- Reads the next character from the stream.
-
readDouble()
- Reads a floating-point number from the stream.
-
readInt()
- Reads an integer (in decimal) from the stream.
-
readLine()
- Reads a line from the stream
-
readWord()
- Reads a word from the stream.
-
unread(int)
- Returns one character to the input stream, to be read again
TextInputStream
public TextInputStream(String s)
- Constructs a text input stream that reads its input from a file
- Parameters:
- s - the file name
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.
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.
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.
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.
- Overrides:
- read in class InputStream
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
- Overrides:
- close in class InputStream
All Packages Class Hierarchy This Package Previous Next Index