Hi.. I have been trying to figure out how to download the code of an HTML page on the web. I know you can do this with the URL class. Can somebody help me a little bit?
Thank you!
Printable View
Hi.. I have been trying to figure out how to download the code of an HTML page on the web. I know you can do this with the URL class. Can somebody help me a little bit?
Thank you!
:)Code:import java.net.*;
import java.io.*;
class Test
{
public static void main(String[] args)
{
try
{
URL url = new URL("http://www.yahoo.com");
BufferedReader bf = new BufferedReader(new InputStreamReader(url.openStream()));
String s;
while ((s = bf.readLine()) != null)
{
System.out.println(s);
}
bf.close();
}
catch(Exception e){}
}
}
THANKS