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 files |