我试图用这个源代码请求谷歌地理 api
client = new DefaultHttpClient();
HttpGet get=new HttpGet(uri);
try {
HttpResponse response = client.execute(get);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == 200 ){
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
try {
XMLReader parser = XMLReaderFactory.createXMLReader();
parser.setContentHandler(gh);
parser.parse(new InputSource(is));
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}
URI 是不是像这样 http://maps.googleapis.com:80/maps/api/geocode/xml?address =Königstraße, Berlin&sensor=false
抛出异常:非法字符!
我怎样才能逃避 ä,ü,ö,ß 和空白?我尝试使用 ISO-8859-1 作为编码的 java.net.URLEncoder 没有成功:(
问候伊戈尔