Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example borrowed from https://github.com/nostra13/Android-Universal-Image-Loader
- // File: library/src/main/java/com/nostra13/universalimageloader/cache/disc/impl/ext/DiskLruCache.java
- public OutputStream newOutputStream(int index) throws IOException {
- synchronized (DiskLruCache.this) {
- if (entry.currentEditor != this) {
- throw new IllegalStateException();
- }
- if (!entry.readable) {
- written[index] = true;
- }
- File dirtyFile = entry.getDirtyFile(index);
- FileOutputStream outputStream;
- try {
- outputStream = new FileOutputStream(dirtyFile);
- } catch (FileNotFoundException e) {
- // Attempt to recreate the cache directory.
- directory.mkdirs();
- try {
- outputStream = new FileOutputStream(dirtyFile);
- } catch (FileNotFoundException e2) {
- // We are unable to recover. Silently eat the writes.
- return NULL_OUTPUT_STREAM;
- }
- }
- return new FaultHidingOutputStream(outputStream);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement