diff options
Diffstat (limited to 'tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java')
-rw-r--r-- | tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java | 15 |
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); |