I have the block code as follow:
URL url = new URL("http://abc.com");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream());
StringBuilder sb = new StringBuilder();
String str = null;
while (null != (str = reader.readLine())) {
sb = sb.append(str);
}
resStr = sb.toString();
reader.close();
con.disconnect();
There are two input steams that I don't close in the block code above.
First is new InputStreamReader()
and the second is con.getInputStream()
. I have new two input but I don't close them. For that reason, it can be memory leaks?
Note: I'm using jdk1.7.0_21