is the InputStream still usable after a disconnect() is called ?
I want to create a helper class for HTTP requests that will return the InputStream, but closes the connection. is it possible ?
for example:
public InputStream Get(String url) {
URL u = new URL(url);
HttpUrlConnection con = (HttpUrlConnection) url.openConnection();
InputStream in = null;
try {
in = con.getInputStream();
} finally {
con.disconnect();
}
return in;
}
it’s impossible. an inputstream is just a pipe to the server, it doesn’t contain any data.
you may do like this:
}