Class FileResource
- java.lang.Object
-
- org.apache.hc.client5.http.cache.Resource
-
- org.apache.hc.client5.http.impl.cache.FileResource
-
- All Implemented Interfaces:
java.io.Serializable
@Contract(threading=SAFE) public class FileResource extends Resource
Cache resource backed by a file.- Since:
- 4.1
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicReference<java.io.File>fileRefprivate longlenprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description FileResource(java.io.File file)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()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.(package private) java.io.FilegetFile()java.io.InputStreamgetInputStream()Returns resource content as anInputStream.longlength()Returns the length in bytes of the response body.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
fileRef
private final java.util.concurrent.atomic.AtomicReference<java.io.File> fileRef
-
len
private final long len
-
-
Method Detail
-
getFile
java.io.File getFile()
-
get
public byte[] get() throws ResourceIOExceptionDescription copied from class:ResourceReturns 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:
getin classResource- Throws:
ResourceIOException
-
getInputStream
public java.io.InputStream getInputStream() throws ResourceIOExceptionDescription copied from class:ResourceReturns resource content as anInputStream.- Overrides:
getInputStreamin classResource- Throws:
ResourceIOException
-
length
public long length()
Description copied from class:ResourceReturns the length in bytes of the response body.
-
-