// 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);
} 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$
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)));
}
}
} 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)) {
break;
}
}
-
+
mLog = content.toArray(new String[content.size()]);
}
-
+
}
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) {
+ }
+ }
}
}
// 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();
}
} else {\r
sourceProp = new File(toolsdir, SdkConstants.FN_SOURCE_PROP);\r
}\r
- p.load(new FileInputStream(sourceProp));\r
+ FileInputStream fis = null;\r
+ try {\r
+ fis = new FileInputStream(sourceProp);\r
+ p.load(fis);\r
+ } finally {\r
+ if (fis != null) {\r
+ try {\r
+ fis.close();\r
+ } catch (IOException ignore) {\r
+ }\r
+ }\r
+ }\r
+\r
String revision = p.getProperty(PkgProps.PKG_REVISION);\r
if (revision != null) {\r
return revision;\r
} 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;