public class FileCache extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
FileCache.Validator
An interface to be implemented by cache validators
|
Modifier and Type | Field and Description |
---|---|
private File |
cache |
private static ByteFormat |
format |
private static File |
home |
private PrintStream |
print |
Constructor and Description |
---|
FileCache()
Create a FileCache using the default cache location
|
FileCache(File cacheDirectory)
Create a file cache using an explicit cache location
|
Modifier and Type | Method and Description |
---|---|
File |
getCachedFile(URL url)
Get a file from the cache.
|
File |
getCachedFile(URL url,
FileCache.Validator validator)
Get a file from the cache.
|
File |
getCacheDirectory()
Get the directory used for caching
|
static File |
getCacheRoot() |
PrintStream |
getPrintStream()
Gets the print stream used for diagnostic messages if a file is
downloaded.
|
void |
setCacheDirectory(File cacheDirectory)
Set a new cache directory location
|
void |
setPrintStream(PrintStream printStream)
Set the print stream to be used for diagnostic messages
|
private static final File home
private static final ByteFormat format
private File cache
private PrintStream print
public FileCache() throws IOException
IOException
- If the cache directory cannot be createdpublic FileCache(File cacheDirectory) throws IOException
cacheDirectory
- The directory to use for storing cached filesIOException
- If the cache directory cannot be createdpublic static File getCacheRoot()
public File getCachedFile(URL url) throws IOException
url
- The URL of the file to downloadIOException
- If the file cannot be downloaded, or if an
error occurs writing to the cache.public File getCachedFile(URL url, FileCache.Validator validator) throws IOException
url
- Teh URL of the file to downloadvalidator
- A Validator that will be used to check the integrity of
the downloaded file before it is placed in the cacheIOException
- If the file cannot be downloaded, or if an
error occurs writing to the cache, or if the file fails
validation.public File getCacheDirectory()
public void setCacheDirectory(File cacheDirectory) throws IOException
cacheDirectory
- The directory to use.IOException
- If the specified directory cannot be created,
or already exists and is not a directory.public PrintStream getPrintStream()
null
if none
exists.public void setPrintStream(PrintStream printStream)
printStream
- The print stream to use, or null
to
disable diagnostic messagesCopyright © 2016 Linear Collider Detector (LCD). All rights reserved.