org.apache.hc.client5.http.cache

## Class Resource

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

- All Implemented Interfaces:
    Serializable
  Direct Known Subclasses:
    FileResource, HeapResource

      @Contract(threading=SAFE)
      public abstract class Resource
      extends Object
      implements Serializable

  Represents a disposable system resource used for handling cached response bodies.

  Implementations of this interface are expected to be threading-safe.

  Since:
    4.1
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Resource()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `dispose()` Indicates the system no longer needs to keep this response body and any system resources associated with it may be reclaimed.
    `abstract byte[]` | `get()` Returns resource content as a byte array.
    `InputStream` | `getInputStream()` Returns resource content as a `InputStream`.
    `abstract 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

    - #### Resource

          public Resource()

  - ### Method Detail

    - #### getInputStream

          public InputStream getInputStream()
                                     throws ResourceIOException

      Returns resource content as a `InputStream`.
      Throws:
        `ResourceIOException`

    - #### get

          public abstract byte[] get()
                              throws ResourceIOException

      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.

      Throws:
        `ResourceIOException`
      Since:
        5.0

    - #### length

          public abstract long length()

      Returns the length in bytes of the response body.

    - #### dispose

          public abstract void dispose()

      Indicates the system no longer needs to keep this response body and any system resources associated with it may be reclaimed.

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