From 89b5053816c2b99f17ebd08e9716dbbe9e643ddb Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 9 Nov 2012 20:15:28 +0100 Subject: [PATCH] close streams where appropriate --- .../android/AndroidDocumentationProvider.java | 66 ++++++++++--------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/plugins/android/src/org/jetbrains/android/AndroidDocumentationProvider.java b/plugins/android/src/org/jetbrains/android/AndroidDocumentationProvider.java index 75744a8fff07..52680edaa34e 100644 --- a/plugins/android/src/org/jetbrains/android/AndroidDocumentationProvider.java +++ b/plugins/android/src/org/jetbrains/android/AndroidDocumentationProvider.java @@ -133,44 +133,48 @@ public class AndroidDocumentationProvider implements DocumentationProvider, Exte return; } final BufferedReader buf = new BufferedReader(input); + try { + @NonNls String startSection = ""; + @NonNls String endHeader = ""; - @NonNls String startSection = ""; - @NonNls String endHeader = ""; + data.append(HTML); - data.append(HTML); + String read; - String read; - - do { - read = buf.readLine(); - } - while (read != null && read.toUpperCase().indexOf(startSection) == -1); - - if (read == null) { - data.delete(0, data.length()); - return; - } - - data.append(read).append("\n"); - - boolean skip = false; - while (((read = buf.readLine()) != null) && read.toLowerCase().indexOf("class overview") < 0) { - if (!skip && read.length() > 0) { - data.append(read).append("\n"); + do { + read = buf.readLine(); } - if (read.toUpperCase().indexOf(endHeader) != -1) { - skip = true; - } - } + while (read != null && read.toUpperCase().indexOf(startSection) == -1); - if (read != null) { - data.append("
\n"); - while (((read = buf.readLine()) != null) && !read.toUpperCase().startsWith("

")) { - data.append(read).append("\n"); + if (read == null) { + data.delete(0, data.length()); + return; } - data.append("

\n"); + + data.append(read).append("\n"); + + boolean skip = false; + while (((read = buf.readLine()) != null) && read.toLowerCase().indexOf("class overview") < 0) { + if (!skip && read.length() > 0) { + data.append(read).append("\n"); + } + if (read.toUpperCase().indexOf(endHeader) != -1) { + skip = true; + } + } + + if (read != null) { + data.append("
\n"); + while (((read = buf.readLine()) != null) && !read.toUpperCase().startsWith("

")) { + data.append(read).append("\n"); + } + data.append("

\n"); + } + data.append(HTML_CLOSE); + } + finally { + buf.close(); } - data.append(HTML_CLOSE); } catch (Exception e) { LOG.error(e.getMessage(), e, "URL: " + surl);