Write a java program that will open a file, read each of the records from the file, use that data to populate a two dimensional array and write the sorted data out to a new text file.
Define a class named Munge which will do all the 'heavy lifting' in this program.
Build your project in NetBeans using the Run - Build Project, or Run - Clean and Build Project menu item.
From the dist directory you will execute your program from the command line with two filenames as arguments, input file name and output file name. For example:
java -jar lab5.jar ..\input.txt ..\output.txt
The input file will be a plain text file with one city name followed by a comma, followed by a single space, followed by the name of the province. The input file will have no more than 15 cities from one province so you can hard-code that value into your program when you are defining the size of your array. Some provinces may not exist in the data. The input file could be empty and your program should still run fine. Hand in all the input files you used to show how your data design helped to thoroughly test your software.
The output file will consist of the name of a province (assuming it has at least one city) followed by a colon, followed by a space a then a list of the cities from that province sorted alphabetically. The list of cities is comma separated. Notice the last city does not have a comma after it.
The provinces are sorted west to east followed by the three territories also from west to east.
The data must be stored in a two dimensional array of java Strings. Index 0 will represent the array of city Strings from British Columbia, index 1 will represent the array of city Strings from Alberta ... index 11 will represent the array of city Strings from Nunavut. By structuring it this way the provinces are already sorted.
When opening the files, catch the following exceptions: FileNotFoundException and SecurityException. Exit the program cleanly with an informative message to the user if these occur.
When reading records from the input file catch a NoSuchElementException and exit your program cleanly with an informative error message if this occurs.
When writing data to the output file catch a FormatterClosedException and exit your program cleanly with an informative error message if this occurs.

sample input
Hamilton, Ontario
Montreal, Quebec
Vancouver, British Columbia
Sarnia, Ontario
Sherbrooke, Quebec
Winnipeg, Manitoba
Red Deer, Alberta
Edmonton, Alberta
Niagara Falls, Ontario
Port Elgin, Ontario
Victoria, British Columbia
Truro, Nova Scotia
Regina, Saskatchewan
Kingston, Ontario
Fredricton, New Brunswick
Grand Prarie, Alberta
Calgary, Alberta
Collingwood, Ontario

sample output
British Columbia: Vancouver, Victoria
Alberta: Calgary, Edmonton, Grand Prarie, Red Deer
Saskatchewan: Regina
Manitoba: Winnipeg
Ontario: Collingwood, Hamilton, Kingston, Niagara Falls, Port Elgin, Sarnia
Quebec: Montreal, Sherbrooke
New Brunswick: Fredricton
Nova Scotia: Truro

jwenting commented: silly homework kiddos -3

good luck with your homework

Finished. What does your's look like?

I'm in my first year software development program..
I need help help with this assingment aswell please..
I've spent hours working on it and still can't get it working properly;
Thanks

so ... the OP was too lazy to work on it himself, you just hijack this thread and expect us to solve it for you?
and if that's not enough, you then go and copy-paste the assignment to create a new identical thread???

mwa .. mwaaaaa ..

hope you're not expecting high marks on java development this year.

commented: This is not in any way negative. This is correct. Whichever idiot thought that they could not do their homework is lazy, and ignorant. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.