• Log in or sign up for an account here: https://www.sythe.org/login

HTML Downloader

Swan

When They Cry...
Joined
Jan 23, 2007
Sythe Gold
0
Messages
4,957
Age
32
Location
Australia
HTML Downloader
Uses BufferedReader, InputStreamReader, and URL to download and display the contents of an HTML file.

Code:
package htmldownloader;

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

/**
 *
 * @author Dave
 */
public class Main {
    public static void main(String[] args) {
        try {
            URL aURL = new URL("http://www.yahoo.com");
            BufferedReader in = new BufferedReader(new InputStreamReader(aURL.openStream()));
            String line;
            
            while((line = in.readLine()) != null)
                System.out.println(line);
        } catch(MalformedURLException exc) {
            System.out.println("Error! Malformed URL!");
        } catch(IOException exc) {
            System.out.println("Java I/O Exception!");
        }        
    }
}

credits to sun and their tutorials.
 
HTML Downloader
FAIL. Mine is > yours
Code:
 public String wget(String url) throws Throwable {     return wget(new URL(url)); }  public String wget(URL url) throws Throwable {     URLConnection urlc = url.openConnection();     DataInputStream dis = new DataInputStream(url.getInputStream());     byte[] buff = new byte[urlc.getContentLength()];     dis.readFully(buff);     return new String(buff); }
 
Runescape Gamblingrunescape gambling
Back
Top