Class DiskLruCache.Snapshot

java.lang.Object
com.squareup.okhttp.internal.DiskLruCache.Snapshot
All Implemented Interfaces:
Closeable, AutoCloseable
Enclosing class:
DiskLruCache

public final class DiskLruCache.Snapshot
extends Object
implements Closeable
A snapshot of the values for an entry.
  • Method Details

    • edit

      public DiskLruCache.Editor edit() throws IOException
      Returns an editor for this snapshot's entry, or null if either the entry has changed since this snapshot was created or if another edit is in progress.
      Throws:
      IOException
    • getInputStream

      public InputStream getInputStream​(int index)
      Returns the unbuffered stream with the value for index.
    • getString

      public String getString​(int index) throws IOException
      Returns the string value for index.
      Throws:
      IOException
    • getLength

      public long getLength​(int index)
      Returns the byte length of the value for index.
    • close

      public void close()
      Description copied from interface: Closeable
      Closes the object and release any system resources it holds.

      Although only the first call has any effect, it is safe to call close multiple times on the same object. This is more lenient than the overridden AutoCloseable.close(), which may be called at most once.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable