I was trying to build a crawler that collects HTML sourcecodes from websites, which I have in a .csv file. Everything seems to be working fine whenever I place the link in
url = new URL ("http://example.com")
but whenever I try to place the link in a variable ("text" in this example) I get an error, telling me that there has been a malformedURLException.
Here is my code:
String text ="http://stackoverflow.com/questions/9827143/continuing-execution-after-an-exception-is-thrown-in-java";
// get the sourcecode of the link you just grabbed
url = new URL(text);
PrintWriter writer = new PrintWriter("sourcecode.txt", "UTF-8");