public class TextInputFile
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed
Set if the file has been closed.
|
protected static int |
EMPTY
Constants and variables used by the input line buffer.
|
protected boolean |
eofFlag
The end-of-file flag
|
protected java.io.BufferedReader |
f
Stream used for reading input.
|
protected java.lang.String |
fileName
The file name.
|
protected java.lang.String |
lineBuffer |
protected boolean |
useStandardIO
Indicator whether to write to standard output or a file.
|
| Constructor and Description |
|---|
TextInputFile()
Contructor - TextInputFile to read from standard input.
|
TextInputFile(java.io.File file)
Contructor - TextInputFile to read from a File.
|
TextInputFile(java.lang.String fileName)
Contructor - TextInputFile to read from file with specified name.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the file to further reading.
|
boolean |
eof()
Return whether there is an eof before the next token.
|
protected void |
pushACharacter(char ch)
Place the character in the unread position.
|
protected char |
readACharacter()
Read a single character from the file.
|
protected char |
readACharacterThrowsEOF()
Read a single character from the file.
|
protected void |
readALineFromFile()
Reads a line from the file.
|
protected java.lang.String |
readAToken()
Reads in input from the keyboard buffer until it hits a
whitespace, which indicates the end of a token.
|
boolean |
readBoolean()
Read a boolean from the file.
|
byte |
readByte()
Read an 8-bit integer (a "byte") from the file.
|
char |
readChar()
Read a single character from the file.
|
double |
readDouble()
Read a double precision floating point number (a "double") from
the file.
|
float |
readFloat()
Read a floating point number (a "float") from the file.
|
int |
readInt()
Read a 32-bit integer (an "int") from the file.
|
java.lang.String |
readLine()
Read a full line of text from the file.
|
long |
readLong()
Read a 64-bit integer (a "long") from the file.
|
short |
readShort()
Read a 16-bit integer (a "short") from the file.
|
java.lang.String |
readString()
Read a whitespace delimited token from the file.
|
protected java.lang.String fileName
protected java.io.BufferedReader f
protected boolean closed
protected boolean useStandardIO
protected boolean eofFlag
protected static final int EMPTY
protected java.lang.String lineBuffer
public TextInputFile()
public TextInputFile(java.io.File file)
file - - File to be opened.public TextInputFile(java.lang.String fileName)
fileName - - Name of the file to be opened.public void close()
public boolean eof()
protected void pushACharacter(char ch)
ch - - The character to be pushed into the unread position.protected char readACharacter()
protected char readACharacterThrowsEOF()
throws java.io.EOFException
java.io.EOFException - - Thrown if attempt to read past EOF.protected void readALineFromFile()
throws java.io.EOFException
java.io.EOFException - - Thrown if attempt to read past EOF.protected java.lang.String readAToken()
public boolean readBoolean()
public byte readByte()
public char readChar()
public double readDouble()
public float readFloat()
public int readInt()
public java.lang.String readLine()
public long readLong()
public short readShort()
public java.lang.String readString()