// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.IOException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class Something {
    public static void something() {
        try {
            String urlstr = "http://arne1.vajhoej.dk/index.html";
            String fnm = "index.html";
            URL url = new URL(urlstr);
            HttpURLConnection con = (HttpURLConnection)url.openConnection();
            con.connect();
            if(con.getResponseCode() == HttpURLConnection.HTTP_OK) {
                InputStream is = con.getInputStream();
                OutputStream os = new FileOutputStream(fnm);
                byte[] b = new byte[100000];
                int n;
                while((n = is.read(b)) >= 0) {
                    os.write(b,0,n);
                }
                os.close();
                is.close();
             }
             con.disconnect();
         } catch (MalformedURLException e) {
             e.printStackTrace();
         } catch (IOException e) {
             e.printStackTrace();
         }
    }
}
