我試圖請求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