How we can Download a HTML Page using JAVA??
+1
A:
Here is the code:
URL myUrl = new URL("http://www.somepage.com/");
BufferedReader in = new BufferedReader(
new InputStreamReader(
myUrl.openStream()));
String line;
while ((line = in.readLine()) != null)
System.out.println(line);
in.close();
Now you can process one line after one other in the while loop.
Klark
2010-07-27 07:43:19
@SiNTER :can i add this stuff into my MySQL? how can i do that?
2010-07-27 07:45:25
Of course you can. You can build some sting buffer from each line and put it in the database.
Klark
2010-07-27 08:01:41
@SiNter : Thks...
2010-07-27 08:02:52
A:
If you have more requirements, like authentication, you can use HttpClient
rlovtang
2010-07-27 07:52:24
@rlovtang : No i just need to fetch the page and download it to my database, as for web index
2010-07-27 07:54:23
I mean that you will probably do fine with SINTER's solution. You can of course use HttpClient if you like.
rlovtang
2010-07-27 08:18:18