Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 680041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:19:37+00:00 2026-05-14T01:19:37+00:00

I want city name from IP address using Java is there any idea to

  • 0

I want city name from IP address using Java

is there any idea to do this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:19:38+00:00Added an answer on May 14, 2026 at 1:19 am

    From Andrey link, here is how to construct the inquiry, this code will return an HTML file with all details of current IP, including city;

    String IP= "123.123.123.123";
    URL link = new URL("http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress="+IP);
    
    BufferedReader in = new BufferedReader(new InputStreamReader(link.openStream()));
    String inputLine;
    
    while ((inputLine = in.readLine()) != null){
         System.out.println(inputLine);             
    }
    
    in.close();
    

    UPDATE, 23 May 2013

    The previous answer is ok, but it’s not an API call, it reads an HTML page, that I provided previously because I didn’t find any free APIs. Next is a REST API call that can be used easily and will return all the info required, it’s recommended to use this one:

    String ip = "2.51.255.200"; 
    URL url = new URL("http://freegeoip.net/csv/" + ip);
    connection = (HttpURLConnection) url.openConnection();
    connection.connect();
    
    InputStream is = connection.getInputStream();
    
    int status = connection.getResponseCode();
    if (status != 200) {
        return null;
    }
    
    reader = new BufferedReader(new InputStreamReader(is));
    for (String line; (line = reader.readLine()) != null;) {
        //this API call will return something like:
        "2.51.255.200","AE","United Arab Emirates","03","Dubai","Dubai","","x-coord","y-coord","",""
        // you can extract whatever you want from it
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to remove a backslash character from this string: String result = [{\venues\:{\venueId\:1,\name\:\First
Here is my code.. I want to find just a name of city from
I want to fetch data from json array using java gson library following is
i want to create one textbox which accept city or country name and when
I have a codeigniter webform, I want to input city/state details from the user,
I have address table in which city field have nvarchar datatype, but I want
I want to add some data which I get from user using html form
I'm using the Foursquare API, and I want to extract the id value from
I want to create a city filled with virtual creatures. Say like Sim City,
I want to create a simple app that shows me the city of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.