Closing BufferedReader and InputStreamReader
问题 This piece of code is creating memory leak issues cause of BufferedReader and InputStreamReader which I think might be happening cause of some exceptions. How should I change it? try{ URL url = new URL(sMyUrl); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); while ((str = in.readLine()) != null) { jsonString += str; } in.close(); }catch(Exception e){ } 回答1: It would be safer to close your stream using a try..finally block. You might also use a StringBuilder as