Advertisement
happy-barney

catch example - java 02 - proposal

Jun 25th, 2020
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. // Example borrowed from https://github.com/nostra13/Android-Universal-Image-Loader
  2. // File: library/src/main/java/com/nostra13/universalimageloader/cache/disc/impl/ext/DiskLruCache.java
  3.  
  4.     public OutputStream newOutputStream(int index) throws IOException {
  5.         synchronized (DiskLruCache.this) {
  6.             if (entry.currentEditor != this) {
  7.                 throw new IllegalStateException();
  8.             }
  9.             if (!entry.readable) {
  10.                 written[index] = true;
  11.             }
  12.             File dirtyFile = entry.getDirtyFile(index);
  13.             FileOutputStream outputStream;
  14.  
  15.             catch (FileNotFoundException e) {
  16.                 catch (FileNotFoundException e) { return NULL_OUTPUT_STREAM; }
  17.                 directory.mkdirs();
  18.                 continu RETRYABLE;
  19.             }
  20.  
  21.             RETRYABLE:
  22.             outputStream = new FileOutputStream(dirtyFile);
  23.  
  24.             return new FaultHidingOutputStream(outputStream);
  25.         }
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement