I am trying to find the number of words in the website.
But when I run it I keep getting:
...cannot find symbol
catch(MalFormerdURLException ex)
I imported the necessary packages and it's still not working
import java.util.Scanner;
import java.net.MalformedURLException;
import java.io.IOException;
import java.net.URL;
public class CountWords{
public static void main(String[] args) throws Exception{
String URL = "http://websitetips.com/articles/copy/lorem/ipsum.txt";
URL url;
try{
url = new URL(URL);
int count = 0;
Scanner input = new Scanner(url.openStream());
while(input.hasNext()){
String line = input.nextLine();
count += line.length();
}
System.out.println(count);
}
catch(MalFormedURLException ex){
System.out.println("Invalid URL");
}
catch(IOException ex){
System.out.println("IO Errors");
}
}
}