调用 disconnect() 后 InputStream 是否仍然可用?
我想为将返回 InputStream 但关闭连接的 HTTP 请求创建一个帮助程序类。可能吗 ?
例如:
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;
}