public class DiskCache extends Object
Modifier and Type | Field and Description |
---|---|
static DiskCache |
INSTANCE
A global shared Disk cache.
|
Modifier and Type | Method and Description |
---|---|
protected void |
finalize()
Never called; here for JRE compatibility.
|
byte[] |
readByteArray(long token)
Retrieve the underlying bytes.
|
<T> T |
readObject(long token,
Class<T> type)
Deserialize the underlying bytes as an object.
|
String |
readString(long token)
Read the underlying bytes as a String.
|
long |
transferFromStream(InputStream in)
Write the rest of the data in an input stream to disk.
|
void |
transferToStream(long token,
OutputStream out)
Writes the underlying bytes into the specified output stream.
|
long |
writeByteArray(byte[] bytes)
Write a byte array to disk.
|
long |
writeObject(Object object)
Serialize an Object to disk.
|
long |
writeString(String str)
Write a String to disk as bytes.
|
public static DiskCache INSTANCE
public byte[] readByteArray(long token)
token
- a previously returned tokenpublic <T> T readObject(long token, Class<T> type)
T
- the type of the object to deserializetoken
- a previously returned tokentype
- the type of the object to deserializepublic String readString(long token)
token
- a previously returned tokenpublic long transferFromStream(InputStream in) throws IOException
in
- open stream containing the data to write to the disk cache.IOException
public void transferToStream(long token, OutputStream out) throws IOException
token
- a previously returned tokenout
- the stream to write intoIOException
public long writeByteArray(byte[] bytes)
public long writeObject(Object object)
public long writeString(String str)
Copyright © 2018. All rights reserved.