Results 1 to 3 of 3

Thread: URL class

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Posts
    843

    URL class

    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!
    "The difference between mad and genius is the success"

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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){}
    	}
    }
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Posts
    843
    THANKS
    "The difference between mad and genius is the success"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width