public void getWebContent() throws Exception {
Scanner in = new Scanner(System.in);
System.out.println("Input URL:");
fileURL = in.nextLine();
if (!fileURL.startsWith("http://")) {
System.out.println("URL not valid! Please make sure 'http://' prefixes");
System.out.println("the web address!");
} else {
Scanner url = new Scanner(new URL(fileURL).openStream());
System.out.println("Here are the contents:");
while (url.hasNextLine()) {
System.out.println(url.nextLine());
}
System.out.println("Would you like this to be your new Diary?");
command = in.nextLine();
if (command.equalsIgnoreCase("yes")) {
diary.clear();
while (url.hasNextLine()) {
diary.add(url.nextLine());
}
System.out.println("New Diary created.");
} else {
System.out.println("Download cancelled. Returning to first command entry.");
}
}
}
So as far as I know, this method getWebContent()
works just fine up until it is trying to add the read web file into ArrayList<String> diary
. I honestly don't know what's wrong, but I know you smartie-pants out there can figure it out :)!