Java   View all facts   Glossary   Help
action
Next kbTopassociation    UpkbTop    Previous kbTopaccess mode   

action comparison table
Subject have syntax
reading from a file
//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();
writing to a file
//Instantiate a stream, and a PrintWriter
FileOutputStream streamVariableName = new FileOutputStream(fileNameOrPath);
PrintWriter printerVariableName = new PrintWriter(streamVariableName)
//Write a string to the file
printerVariableName.print(string);
//Write a string and a newline to the file
printerVariableName.println(string);
//Close the file
streamVariableName.close();

Next kbTopassociation    UpkbTop    Previous kbTopaccess mode