diff options
7 files changed, 95 insertions, 15 deletions
diff --git a/anttasks/src/com/android/ant/TaskHelper.java b/anttasks/src/com/android/ant/TaskHelper.java index a360eaf..8a3d6bc 100644 --- a/anttasks/src/com/android/ant/TaskHelper.java +++ b/anttasks/src/com/android/ant/TaskHelper.java @@ -59,7 +59,20 @@ final class TaskHelper { // tools folder must exist, or this custom task wouldn't run! File toolsFolder= new File(sdkFile, SdkConstants.FD_TOOLS); File sourceProp = new File(toolsFolder, SdkConstants.FN_SOURCE_PROP); - p.load(new FileInputStream(sourceProp)); + + FileInputStream fis = null; + try { + fis = new FileInputStream(sourceProp); + p.load(fis); + } finally { + if (fis != null) { + try { + fis.close(); + } catch (IOException ignore) { + } + } + } + String value = p.getProperty("Pkg.Revision"); //$NON-NLS-1$ if (value != null) { return Integer.parseInt(value); diff --git a/ddms/app/src/com/android/ddms/Main.java b/ddms/app/src/com/android/ddms/Main.java index 583feb5..6fe69c7 100644 --- a/ddms/app/src/com/android/ddms/Main.java +++ b/ddms/app/src/com/android/ddms/Main.java @@ -144,7 +144,19 @@ public class Main { } else { sourceProp = new File("source.properties"); //$NON-NLS-1$ } - p.load(new FileInputStream(sourceProp)); + FileInputStream fis = null; + try { + fis = new FileInputStream(sourceProp); + p.load(fis); + } finally { + if (fis != null) { + try { + fis.close(); + } catch (IOException ignore) { + } + } + } + sRevision = p.getProperty("Pkg.Revision"); //$NON-NLS-1$ if (sRevision != null && sRevision.length() > 0) { stats.ping("ddms", sRevision); //$NON-NLS-1$ diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/BugReportImporter.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/BugReportImporter.java index 9de1ac7..da41e70 100644 --- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/BugReportImporter.java +++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/BugReportImporter.java @@ -24,14 +24,14 @@ import java.io.InputStreamReader; import java.util.ArrayList; public class BugReportImporter { - + private final static String TAG_HEADER = "------ EVENT LOG TAGS ------"; private final static String LOG_HEADER = "------ EVENT LOG ------"; private final static String HEADER_TAG = "------"; - + private String[] mTags; private String[] mLog; - + public BugReportImporter(String filePath) throws FileNotFoundException { BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(filePath))); @@ -45,20 +45,27 @@ public class BugReportImporter { } } } catch (IOException e) { + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException ignore) { + } + } } } - + public String[] getTags() { return mTags; } - + public String[] getLog() { return mLog; } private void readTags(BufferedReader reader) throws IOException { String line; - + ArrayList<String> content = new ArrayList<String>(); while ((line = reader.readLine()) != null) { if (LOG_HEADER.equals(line)) { @@ -82,8 +89,8 @@ public class BugReportImporter { break; } } - + mLog = content.toArray(new String[content.size()]); } - + } diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogImporter.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogImporter.java index a1303f6..011bcf1 100644 --- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogImporter.java +++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogImporter.java @@ -47,6 +47,19 @@ public class EventLogImporter { readTags(tagReader); readLog(eventReader); } catch (IOException e) { + } finally { + if (tagReader != null) { + try { + tagReader.close(); + } catch (IOException ignore) { + } + } + if (eventReader != null) { + try { + eventReader.close(); + } catch (IOException ignore) { + } + } } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java index d12f168..479098d 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java @@ -345,9 +345,19 @@ public final class ExportHelper { // put the content of the file. byte[] buffer = new byte[1024]; int count; - BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); - while ((count = bis.read(buffer)) != -1) { - jar.write(buffer, 0, count); + BufferedInputStream bis = null; + try { + bis = new BufferedInputStream(new FileInputStream(file)); + while ((count = bis.read(buffer)) != -1) { + jar.write(buffer, 0, count); + } + } finally { + if (bis != null) { + try { + bis.close(); + } catch (IOException ignore) { + } + } } jar.closeEntry(); } diff --git a/sdkmanager/app/src/com/android/sdkmanager/internal/repository/AboutPage.java b/sdkmanager/app/src/com/android/sdkmanager/internal/repository/AboutPage.java index ba552e3..a12268c 100755 --- a/sdkmanager/app/src/com/android/sdkmanager/internal/repository/AboutPage.java +++ b/sdkmanager/app/src/com/android/sdkmanager/internal/repository/AboutPage.java @@ -111,7 +111,19 @@ public class AboutPage extends UpdaterPage { } else {
sourceProp = new File(toolsdir, SdkConstants.FN_SOURCE_PROP);
}
- p.load(new FileInputStream(sourceProp));
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(sourceProp);
+ p.load(fis);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException ignore) {
+ }
+ }
+ }
+
String revision = p.getProperty(PkgProps.PKG_REVISION);
if (revision != null) {
return revision;
diff --git a/traceview/src/com/android/traceview/MainWindow.java b/traceview/src/com/android/traceview/MainWindow.java index feb9295..3414d84 100644 --- a/traceview/src/com/android/traceview/MainWindow.java +++ b/traceview/src/com/android/traceview/MainWindow.java @@ -178,7 +178,20 @@ public class MainWindow extends ApplicationWindow { } else { sourceProp = new File(toolsdir, "source.properties"); //$NON-NLS-1$ } - p.load(new FileInputStream(sourceProp)); + + FileInputStream fis = null; + try { + fis = new FileInputStream(sourceProp); + p.load(fis); + } finally { + if (fis != null) { + try { + fis.close(); + } catch (IOException ignore) { + } + } + } + String revision = p.getProperty("Pkg.Revision"); //$NON-NLS-1$ if (revision != null && revision.length() > 0) { return revision; |