A simple tricky program that can read all the html codes of given url using java the following code does that

import java.net.*;
import java.io.*;

public class URLReader {
    public static void main(String[] args) throws Exception {
	URL yahoo = new URL("http://www.yahoo.com");
	BufferedReader in = new BufferedReader(
				new InputStreamReader(
				yahoo.openStream()));

	String inputLine;

	while ((inputLine = in.readLine()) != null)
	    System.out.println(inputLine);

	in.close();
    }
}

Compile and run this java file give any url you want to read in here URL yahoo = new URL(“http://www.yahoo.com”);
Any doubt Ask us Happy coding

Related Posts

  1. create a file from form input in java,jsp