org.apache.hc.client5.http.impl.cache

## Class FileResource

- java.lang.Object
- - org.apache.hc.client5.http.cache.Resource
  - - org.apache.hc.client5.http.impl.cache.FileResource

- All Implemented Interfaces:
    Serializable

      @Contract(threading=SAFE)
      public class FileResource
      extends Resource

  Cache resource backed by a file.
  Since:
    4.1
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileResource(File file)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `dispose()` Indicates the system no longer needs to keep this response body and any system resources associated with it may be reclaimed.
    `byte[]` | `get()` Returns resource content as a byte array.
    `InputStream` | `getInputStream()` Returns resource content as an `InputStream`.
    `long` | `length()` Returns the length in bytes of the response body.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FileResource

          public FileResource(File file)

  - ### Method Detail

    - #### get

          public byte[] get()
                     throws ResourceIOException

      Description copied from class: `Resource`
      Returns resource content as a byte array.

      Please note for memory efficiency some resource implementations may return a reference to the underlying byte array. The returned value should be treated as immutable.

      Specified by:
        `get` in class `Resource`
      Throws:
        `ResourceIOException`

    - #### getInputStream

          public InputStream getInputStream()
                                     throws ResourceIOException

      Description copied from class: `Resource`
      Returns resource content as an `InputStream`.
      Overrides:
        `getInputStream` in class `Resource`
      Throws:
        `ResourceIOException`

    - #### length

          public long length()

      Description copied from class: `Resource`
      Returns the length in bytes of the response body.
      Specified by:
        `length` in class `Resource`

    - #### dispose

          public void dispose()

      Description copied from class: `Resource`
      Indicates the system no longer needs to keep this response body and any system resources associated with it may be reclaimed.
      Specified by:
        `dispose` in class `Resource`

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.