1. Compile and Submit to LiveLab (you must submit the program regardless whether it
complete or incomplete, correct or incorrect)
2. Print this copy.
3. Fill in self-evaluation:
1. Can your program display words only? _______________
2. Can your program display words in increasing order? _______________
3. Can your program count words correctly? _______________
4. Can your program pass argument from the command-line? _______________
Solution:
import java.util.*;
import java.io.*;
// Create a tree map to hold words as key and count as value
TreeMap<String, Integer> treeMap = new TreeMap<>();
try {
java.net.URL url = new java.net.URL(args[0]);
Scanner input = new Scanner(url.openStream());
while (input.hasNext()) {
String line = input.nextLine();
String[] words = line.split(“[ @!~{}\\[\\]$#^&*\n\t\r.,;?’\”)(]”);