private static boolean writeFileContent(File file, InputStream content) { if (file.exists()) { return true; } FileOutputStream out = null; try { out = new FileOutputStream(file); IOUtil.writeToOutput(content, out); return true; } catch (Exception e) { Log.e(TAG, "Error to store file in cache.", e); } finally { IOUtil.close(out); } return false; }
private static InputStream readFileContent(File file) { if (!file.exists()) { return null; } FileInputStream in = null; try { in = new FileInputStream(file); ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtil.writeToOutput(in, out); return new ByteArrayInputStream(out.toByteArray()); } catch (Exception e) { Log.e(TAG, "Error to read file in cache.", e); } finally { IOUtil.close(in); } return null; }