For both parts, if any sort of exception occurs because of bad input such as a
nonexistent file, you should catch it in method main and print "Exception
occurred.". Your program should then terminate.
Hints
• In main, the command will be args[0] and the file names will be args[1],
args[2], and so on.
• Only use System.out.println for output; don't use System.out.print.
• Use a java.util.Scanner to read a file.
• Use a java.util.Set of some kind to store the lines for the "commonstrings"
part, extract them into an array using an appropriate method in java.util.Set,
and sort that array using java.util.Arrays.sort. The sorting order ("collating
sequence") is just the one used for ordinary string comparison, so there's not a
lot of computer science here.
• Use a java.util.List of some kind to store the lines for the "privatemembers"
part, and then Collections.sort to sort the list. The sorting order ("collating
sequence") is again just the one used for ordinary string comparison, so there's
not a lot of computer science here. Make sure you trim whitespace here.
• The previous couple of hints are invitations to read the Java API documentation
(http://java.sun.com/javase/6/docs/api/overview-summary.html).
• Don't ask the user for the file names. They're program arguments.
• Don't print anything but the sorted lines. If you print a header, your mark will be 0.
• You can assume the user actually provides the necessary file names on the
command line, and you don't need to worry that we will try your program on files
that don't contain valid characters.
• You can assume that every line in the input files, including the last, ends with a
newline character.
• You can't assume the number of lines in the file is greater than 0.
• To handle all possible exceptions, wrap the contents of your main method in a
try/catch block and catch Exceptions.