@Test public void testReadPrivateFile() throws Exception { final byte[] data = new byte[] { 0x1, 0x2, 0x3, 0x4, 0xC }; final String fileName = "testFileForRead"; final Context context = RuntimeEnvironment.application; context.deleteFile(fileName); final OutputStream os = context.openFileOutput(fileName, Context.MODE_PRIVATE); ByteStreams.copy(new ByteArrayInputStream(data), os); os.close(); final byte[] read = FileUtils.readPrivateFile(context, fileName); assertArrayEquals(data, read); }
@NonNull public static byte[] readPrivateFile(@NonNull final Context context, @NonNull final String fileName) throws IOException { InputStream is = null; try { is = context.openFileInput(fileName); return ByteStreams.toByteArray(is); } finally { if (is != null) { try { is.close(); } catch (IOException e) { Log.w(TAG, e); } } } }
FileUtils { @NonNull public static byte[] readPrivateFile(@NonNull final Context context, @NonNull final String fileName) throws IOException { InputStream is = null; try { is = context.openFileInput(fileName); return ByteStreams.toByteArray(is); } finally { if (is != null) { try { is.close(); } catch (IOException e) { Log.w(TAG, e); } } } } }
FileUtils { @NonNull public static byte[] readPrivateFile(@NonNull final Context context, @NonNull final String fileName) throws IOException { InputStream is = null; try { is = context.openFileInput(fileName); return ByteStreams.toByteArray(is); } finally { if (is != null) { try { is.close(); } catch (IOException e) { Log.w(TAG, e); } } } } private  FileUtils(); }
FileUtils { @NonNull public static byte[] readPrivateFile(@NonNull final Context context, @NonNull final String fileName) throws IOException { InputStream is = null; try { is = context.openFileInput(fileName); return ByteStreams.toByteArray(is); } finally { if (is != null) { try { is.close(); } catch (IOException e) { Log.w(TAG, e); } } } } private  FileUtils(); @NonNull static byte[] readPrivateFile(@NonNull final Context context,
            @NonNull final String fileName); static boolean writeOrDeletePrivateFile(@NonNull final Context context,
            @NonNull final String fileName,
            @Nullable final byte[] data); }
FileUtils { @NonNull public static byte[] readPrivateFile(@NonNull final Context context, @NonNull final String fileName) throws IOException { InputStream is = null; try { is = context.openFileInput(fileName); return ByteStreams.toByteArray(is); } finally { if (is != null) { try { is.close(); } catch (IOException e) { Log.w(TAG, e); } } } } private  FileUtils(); @NonNull static byte[] readPrivateFile(@NonNull final Context context,
            @NonNull final String fileName); static boolean writeOrDeletePrivateFile(@NonNull final Context context,
            @NonNull final String fileName,
            @Nullable final byte[] data);  }