Closed GoogleCodeExporter closed 9 years ago
Successful request method to use with google app engine using url fetch. (sorry
somehow my browser created a duplicate bug).
public GeocodeResponse geocode(final GeocoderRequest geocoderRequest) {
String surl = null;
try {
surl = getURL(geocoderRequest);
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
String json = null;
try {
URL url = new URL(surl);
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
json = null;
while ((line = reader.readLine()) != null) {
if (json == null) {
json = "";
}
json += line;
}
reader.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
final Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
return gson.fromJson(json, GeocodeResponse.class);
}
Original comment by branflak...@gmail.com
on 6 Feb 2011 at 8:09
Issue 3 has been merged into this issue.
Original comment by panchmp
on 19 Mar 2011 at 5:21
Original comment by panchmp
on 3 Nov 2011 at 7:57
Original issue reported on code.google.com by
branflak...@gmail.com
on 6 Feb 2011 at 8:01