我试图请求Google的地理API与此源代码爪哇:在URI非法字符
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,柏林&传感器=假
,则抛出异常:非法角色!
我怎样才能逃脱ä,ü,ö,ß和空白? 我试图与ISO-8859-1的java.net.URLEncoder中如没有成功:(
问候伊戈尔
你说得对,是这样工作的。谢谢你这么多:) – Igor