We help IT Professionals succeed at work.

how to get latitude and longitude from IP Address using Java

veersudhir83
veersudhir83 asked
on
Dear Team,

I am working out on a useful tool that requires the machine's Latitude and Longitude information from the IP Address. I need to develop this in Java.
Comment
Watch Question

Commented:
Create httprequest to a url like "http://www.geobytes.com/IpLocator.htm?GetLocation&IpAddress=x.x.x.x"
Where x.x.x.x is the ipaddress.
Commented:
Reading from a url in java like this:
import java.net.*;
import java.io.*;

public class URLConnectionReader {
    public static void main(String[] args) throws Exception {
        URL yahoo = new URL("http://www.yahoo.com/");
        URLConnection yc = yahoo.openConnection();
        BufferedReader in = new BufferedReader(
                                new InputStreamReader(
                                yc.getInputStream()));
        String inputLine;

        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
    }
}

Open in new window

Kevin CrossChief Technology Officer
Most Valuable Expert 2011

Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.