
you must complete exercise 8.22 (6th ed, p300) / 8.19 (7th ed, p299) /
9.19 (8th ed, p339).
The class name must be FileIO and it may execute either as a GUI application or as a command line application.
Additional Requirements
- Instead of using the default filename specified in the textbook, you should prompt the user for the filename. This customization will allow you (and me) to test your code without having to comment out the code that tests for overwriting.
- Your randomly generated integers should fall in the range 0 - 999, inclusive. Do not store these numbers upon generation; write them directly to the file.
- When you retrieve the data from the text file, you must first display that data in its unsorted state. After you display the unsorted data, sort the array (you may use Arrays.sort) and then call your print method to display the sorted data.
- Since you will not be handling exceptions explicitly, you will need to add throws Exception after you declare main:
public static void main(String[] args)
throws Exception - You will also need to add throws Exception after the methods which read and write to the file.
- Remember to close your filestreams when you are finished reading or writing to the file. Call close() on your PrintWriter object and also on your Scanner.
Sample Output
Here is a screenshot of my code running.
File IO output
Refer to the deliverables post for comment formatting and required program identification information.
Due Date:
Monday, December 12th, 8:00am