// 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.domain.dk/htbin/tell2?nam=val");
         HttpURLConnection con = (HttpURLConnection)url.openConnection();
         con.connect();
         if(con.getResponseCode() == HttpURLConnection.HTTP_OK) {
            InputStream is = con.getInputStream();
            byte[] b = new byte[1000];
            int n;
            while((n = is.read(b)) >= 0) {
               System.out.println(new String(b,0,n));
            }
            is.close();
         }
         con.disconnect();
      } catch (MalformedURLException e) {
         e.printStackTrace();
      } catch (FileNotFoundException e) {
         e.printStackTrace();
      } catch (IOException e) {
         e.printStackTrace();
      }
   }
}
