當我使用下面的URL在Android上的地圖繪製路線:當urlConnection.getInputStream被稱爲無法打開來自谷歌地圖API在Android的流?
StringBuilder urlString = new StringBuilder();
urlString.append("http://maps.google.com/maps?f=d&hl=en");
urlString.append("&saddr=");
urlString.append(src);
urlString.append("&daddr=");// to
urlString.append(dest);
urlString.append("&ie=UTF8&0&om=0&output=kml");
它投擲例外。
HttpURLConnection urlConnection=(HttpURLConnection)url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.connect();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.parse(urlConnection.getInputStream());
新代碼:
Document doc=null;
try
{
String url = getUrl(p, q);
DocumentBuilderFactory dbfAdd = DocumentBuilderFactory.newInstance();
DocumentBuilder dbAdd = dbfAdd.newDocumentBuilder();
doc = dbAdd.parse(url.toString());
可以請你告訴例外也 – Mikpa 2010-11-28 21:51:23
以前它是「無法打開流」,現在是「的文件意外結束」 。 – Sandy 2010-11-29 04:53:37