I am trying to web scrape some data so that I can use it in my application.
The site I am trying to get data off is yahoo but I am getting a FileNotFoundException when it's trying to stream the data in.
I have also set the IP address and port explicitly.
Would be really thankful if someone can tell me where I am going wrong.
I have posted the sample code as well.
parentUrl = "http://www.yahoo.com";
pageUrl = new URL(parentUrl);
System.out.println(parentUrl);
try {
in = new BufferedReader(new InputStreamReader(pageUrl.openStream()));
} catch(Exception ex2) {
ex2.printStackTrace();
}
while ((inputLine = in.readLine()) != null) {
out.write(inputLine);
in.close();
}
out.close();
out. That'll be where the problem is.in.close()inside your read loop. You'll never be able to read more than one line with this.in.close()from yourwhileloop.