aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-04-02 23:05:16 +0200
committerBananeweizen <bananeweizen@gmx.de>2012-04-02 23:05:16 +0200
commitf0652d4b679eb8039e9ea670dda410b2a34989fb (patch)
tree469680ff1d844c784a0858b421323c750f72012b /tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
parent6eb0503ffd61b1a3399eddd23af3e938d07a33ae (diff)
downloadcgeo-f0652d4b679eb8039e9ea670dda410b2a34989fb.zip
cgeo-f0652d4b679eb8039e9ea670dda410b2a34989fb.tar.gz
cgeo-f0652d4b679eb8039e9ea670dda410b2a34989fb.tar.bz2
refactoring: more static code analysis cleanups
Diffstat (limited to 'tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java')
-rw-r--r--tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
index 906b414..e07a518 100644
--- a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
+++ b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
@@ -16,16 +16,23 @@ public abstract class AbstractResourceInstrumentationTestCase extends Instrument
}
protected String getFileContent(int resourceId) {
- InputStream ins = getInstrumentation().getContext().getResources().openRawResource(resourceId);
- return new Scanner(ins).useDelimiter("\\A").next();
+ final InputStream ins = getResourceStream(resourceId);
+ final String result = new Scanner(ins).useDelimiter("\\A").next();
+ try {
+ ins.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return result;
}
protected void copyResourceToFile(int resourceId, File file) throws IOException {
final InputStream is = getResourceStream(resourceId);
final FileOutputStream os = new FileOutputStream(file);
-
+
try {
- byte[] buffer = new byte[4096];
+ final byte[] buffer = new byte[4096];
int byteCount;
while ((byteCount = is.read(buffer)) >= 0) {
os.write(buffer, 0, byteCount);