我无法获取位于类似地址的文件内容 “HTTP:///127.0.0.1:1935 /应用/ UNIQUE_ID / file.txt的”。该异常说明了主机名 可能是null。我认为问题是由于端口造成的。
如何获取文件内容?
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;
答案 0 :(得分:1)
您提供的示例网址中的“http:”后面看起来有太多斜杠。应该只有两个,如:
http://127.0.0.1:1935/app/unique_id/file.txt