I have a block code as follows:
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 pairs that I do not close in the block code above.
First, new InputStreamReader() , and the second is con.getInputStream() . I have two new inputs, but I do not close them. For this reason, could it be a memory leak?
Note. I am using jdk1.7.0_21
source share