aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
index 12e83cc..e4f8ca5 100644
--- a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
+++ b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
@@ -36,14 +36,19 @@ public abstract class AbstractResourceInstrumentationTestCase extends Instrument
}
protected String getFileContent(int resourceId) {
- final InputStream ins = getResourceStream(resourceId);
- final String result = new Scanner(ins).useDelimiter("\\A").next();
+ Scanner scanner = null;
try {
- ins.close();
- } catch (IOException e) {
+ final InputStream ins = getResourceStream(resourceId);
+ scanner = new Scanner(ins);
+ return scanner.useDelimiter("\\A").next();
+ } catch (Exception e) {
e.printStackTrace();
+ } finally {
+ if (scanner != null) {
+ scanner.close();
+ }
}
- return result;
+ return null;
}
protected void copyResourceToFile(int resourceId, File file) throws IOException {