I’m having a trouble getting the content of a file located at a address similar to
“http:///127.0.0.1:1935/app/unique_id/file.txt”. The exception states that the host name
may be null. I think the problem is due to the port.
How do I get the content of the file?
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;
It looks like you have one too many slashes after the “http:” in the example URL you provided. There should only be two, as in:
http://127.0.0.1:1935/app/unique_id/file.txt