Java   View all facts   Glossary   Help
action > reading from a file
Next actionwriting to a file    Upaction

reading from a file
subjectfact 
reading from a filehas syntax
//Instantiate a stream, reader and tokenizer
FileInputStream streamVariableName = new FileInputStream(fileNameOrPath);
InputStreamReader readerVariableName = new InputStreamReader(streamVariableName);
StreamTokenizer tokenVariableName = new StreamTokenizer(readerVariableName);
//Read from the tokenizer until it is empty
while(tokenVariableName.nextToken() != tokenVariableName.TT_EOF) {
...
}
//Close the file
streamVariableName.close();
added by: JK, source: On To Java, 2001-10-19 11:37:47.0
is a subtopic of Input and Output2001-10-19 11:37:48.0
is a kind of actionadded by: JK, 2001-10-19 11:37:48.0