2012-02-06 41 views
-1

我無法獲取位於類似於 「http:///127.0.0.1:1935/app/UNIQUE_ID/file.txt的」。該例外狀態表示主機名稱 可能爲空。我認爲問題是由於港口。獲取文件內容,拋出「主機名可能爲空」

如何獲取文件的內容?

 final HttpGet httpGet = new HttpGet(url); 
     HttpParams httpParameters = new BasicHttpParams();  
     HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection); 
     HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket); 

     final DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters); 

     InputStream inputStream = timedCall(new Callable<InputStream>() { 
      public InputStream call() throws Exception { 
       HttpResponse response = httpClient.execute(httpGet); 
       return response.getEntity().getContent(); 
      }; 
     }, 10, TimeUnit.SECONDS); 

     return inputStream; 
+2

看起來您在提供的示例URL中的「http:」後面有一個太多的斜線。這可能是問題嗎? – 2012-02-06 21:58:11

+0

哦,對了....嘿..那解決了我的問題......謝謝:) – user634545 2012-02-06 22:03:39

+0

好吧,我會將它作爲答案添加。 – 2012-02-06 22:05:15

回答

1

看起來您在提供的示例網址中的「http:」後面有一個太多的斜槓。應該只有兩個,如: http://127.0.0.1:1935/app/unique_id/file.txt