Writing applications instead of applets so our programs are
allowed to manipulate filesTopWriting files

Writing files

Writing a file requires similar steps:

Here is code from the ShortWords demo to write a file:

// open the stream to write to the file
FileWriter wordWriter = new FileWriter(SHORT_WORDS_FILE);

// write the fixed length words
wordWriter.write(shortWordsArea.getText());
			
// Close the file
wordWriter.close();

This code would again be within a try statement to handle the IOExceptions that might occur. See the complete example for details.


Writing applications instead of applets so our programs are
allowed to manipulate filesTopWriting files