|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
FlexOr.io.BufferedInput
public class BufferedInput
BufferedInput extends the BufferedInputStream by providing the features for simple scanning of input.
The Java file input API read method always returns a character, including an unbounded number of EOF characters when the end of file is reached. Consequently, all input files are implicitly unbounded in length giving the following structure for a file.
file = input[0..N-1 , N, ...]where a file contains the N data characters input[0..N-1] and EOF characters in input[N, N+1, ...].
The EOL character (end-ofline) always counts as one data character. See the method read
Class invariant: currentChar = input[i] => nextChar = input[i+1];
Constructor Summary | |
---|---|
BufferedInput(java.lang.String fileName)
Creating an instance of BufferedInput opens the file named by the String. |
Method Summary | |
---|---|
int |
getCharCount()
Return the number of data characters read from the file. |
int |
getCurrentChar()
The current character is the one to process next from the input file. |
int |
getLineCount()
|
int |
getNextChar()
The next character is a look ahead character. |
int |
read()
Requires: True Ensures: currentChar = old nextChar nextChar = next character from the file or EOF if at the end of file. |
java.lang.String |
readLine()
Requires: currentChar be the first character of the line to read. |
void |
skipToNextLine()
Requires: True Ensures: forall c : old currentChar .. |
void |
skipWhitespaces()
Requires: True Ensures: old currentChar .. |
Methods inherited from class java.io.BufferedInputStream |
---|
available, close, mark, markSupported, read, reset, skip |
Methods inherited from class java.io.FilterInputStream |
---|
read |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BufferedInput(java.lang.String fileName) throws java.io.FileNotFoundException
Requires: True Ensures: currentChar = input[0] // first char in the file
java.io.FileNotFoundException
- when the file named by fileName cannot be
opened.Method Detail |
---|
public int getCurrentChar()
Requires: user called read i times Ensures: result = currentChar and currentChar = input[i-1]
public int getNextChar()
Requires: user called read i times Ensures: result = nextChar and nextChar = input[i]
public int getCharCount()
Requires: True Ensures:i : 0..N-1 | currentChar = input[i] => result = i+1 and i: N, ... | currentChar = input[i] => result = N
public int getLineCount()
public int read()
read
in class java.io.BufferedInputStream
public java.lang.String readLine()
public void skipWhitespaces()
public void skipToNextLine()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |