code: public static DiskLruCache open(File directory, int appVersion, int valueCount, long maxSize)
        throws IOException {
      if (maxSize <= 0) {
        throw new IllegalArgumentException("maxSize <= 0");
      }
      if (valueCount <= 0) {
        throw new IllegalArgumentException("valueCount <= 0");
      }
  
      // If a bkp file exists, use it instead.
      File backupFile = new File(directory, JOURNAL_FILE_BACKUP);
      if (backupFile.exists()) {
        File journalFile = new File(directory, JOURNAL_FILE);
        // If journal file also exists just delete backup file.
        if (journalFile.exists()) {
          backupFile.delete();
        } else {
          renameTo(backupFile, journalFile, false);
        }
      }
  
      // Prefer to pick up where we left off.
      DiskLruCache cache = new DiskLruCache(directory, appVersion, valueCount, maxSize);
      if (cache.journalFile.exists()) {
        try {
          cache.readJournal();
          cache.processJournal();
          cache.journalWriter = new BufferedWriter(
              new OutputStreamWriter(new FileOutputStream(cache.journalFile, true), Util.US_ASCII));
          return cache;
        } catch (IOException journalIsCorrupt) {
          System.out
              .println("DiskLruCache "
                  + directory
                  + " is corrupt: "
                  + journalIsCorrupt.getMessage()
                  + ", removing");
          cache.delete();
        }
      }
  
      // Create a new empty cache.
      directory.mkdirs();
      cache = new DiskLruCache(directory, appVersion, valueCount, maxSize);
      cache.rebuildJournal();
      return cache;
    }
docs: Opens the cache in {@code directory}, creating a cache if none exists
  there.
  
  @param directory a writable directory
  @param valueCount the number of values per cache entry. Must be positive.
  @param maxSize the maximum number of bytes this cache should use to store
  @throws java.io.IOException if reading or writing the cache directory fails