Java   View all facts   Glossary   Help
action > writing to a file
Next actionreading from a file    Upaction

writing to a file
subjectfact 
writing to a filehas syntax
//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();
added by: JK, source: On To Java, 2001-10-19 11:38:17.0
is a subtopic of Input and Output2001-10-19 11:38:17.0
is a kind of actionadded by: JK, 2001-10-19 11:38:18.0