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 8584807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:51:32+00:00 2026-06-11T21:51:32+00:00

I am using google geocoding api to get the results but it is returning

  • 0

I am using google geocoding api to get the results but it is returning “ZERO_RESULTS”. Below is the code

public class GeoCode {

public static void main(String[] args) throws Exception {
    GeoCode.geocode("latlng=40.714224,-73.961452");
    }
private static final String URL = "http://maps.googleapis.com/maps/api/geocode/json";


public static void geocode(String address) throws Exception {

    URL url = new URL(URL + "?" + URLEncoder.encode(address, "UTF-8") + "&sensor=false");
    URLConnection conn = url.openConnection();
    ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
    IOUtils.copy(conn.getInputStream(), output);
    output.close();

    //JSONObject json = new JSONObject(output.toString());
    System.out.println(output.toString());
}
}

When I use the address manually on the address bar of the browser it shows me the json result on the browser. But what is actually wrong with the above code, that it is returning “ZERO_RESULTS” in a json?

  • 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-06-11T21:51:34+00:00Added an answer on June 11, 2026 at 9:51 pm

    You need not encode the address with URLEncoder, just do:

    URL url = new URL(URL + "?" + address + "&sensor=false");
    URLConnection conn = url.openConnection();
    ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
    IOUtils.copy(conn.getInputStream(), output);
    output.close();
    System.out.println(output.toString());
    

    or maybe better:

       URL url = new URL("http://maps.googleapis.com/maps/api/geocode/json?" + address + "&sensor=false");
    try {
        output = new Scanner(url.openStream()).useDelimiter("\\A").next());
    } catch (java.util.NoSuchElementException e) {
        //empty result
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using http://code.google.com/apis/maps/documentation/geocoding/ api from google to get geolocation based on address. I
I am using the Google Geocoding API v3[1] from an iOS application but can't
Im trying to geocode in my javascript code against Geocoding API. I get url
I am using the following code to use get-directions in google maps. But when
I am currently using the google maps' reverse geocoding API to convert long/lat received
I am using reverse geocoding in Google Maps to get an address from a
I am trying to do some basic geocoding using the google maps API and
I've seen many posts about the Google Geocoding API, described here: http://code.google.com/apis/maps/documentation/geocoding/ but none
I have a requirement to geocode data using Google's geocoding service. Google's geocoding services
I'm doing some geocoding using the google maps API. The user fill a form

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.