// 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.net.*;
import java.io.*;

public class HttpGet {
   public static void main(String[] args) {
      try {
         URL url = new URL("http://www.eksperten.dk/");
         HttpURLConnection con = (HttpURLConnection)url.openConnection();
         con.connect();
         if(con.getResponseCode() == HttpURLConnection.HTTP_OK) {
            InputStream is = con.getInputStream();
            OutputStream os = new FileOutputStream("z.z");
            byte[] b = new byte[1000];
            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 (FileNotFoundException e) {
         e.printStackTrace();
      } catch (IOException e) {
         e.printStackTrace();
      }
   }
}
