【发布时间】:2012-05-16 07:55:47
【问题描述】:
我试图用这个源代码请求 googles geo 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 没有成功:(
问候伊戈尔
【问题讨论】: