/* Call with * java GetLatHttp geocoder.us 80 /service/rest/geocode?address=1250+S+Bellflower+Blvd,+Long+Beach+CA */ import java.net.*; import java.io.*; public class GetLatHttp { public static void main(String [] args) { String s; if (args.length != 3){ System.out.println("Usage: java GetLatHttp host port request"); System.exit(1); } try { int port = Integer.parseInt(args[1]); Socket server = new Socket(args[0],port); System.out.println("Connected to host " + server.getInetAddress()); BufferedReader fromServer = new BufferedReader (new InputStreamReader(server.getInputStream())); PrintWriter toServer = new PrintWriter (server.getOutputStream(),true); toServer.println("GET " + args[2] + " HTTP/1.0"); toServer.println("Host: " + args[0]+ ':' + args[1]); toServer.println("Content-Type: application/x-www-form-urlencoded"); toServer.println(); while (!(s=fromServer.readLine()).equals("")) System.out.println(s); int i; while ((i=fromServer.read()) != -1) System.out.print((char)i); fromServer.close(); toServer.close(); server.close(); }catch(Exception e) { e.printStackTrace(); } } }