org.jurvis.util
Class JvFileCache

java.lang.Object
  extended by org.jurvis.util.JvFileCache

public class JvFileCache
extends Object

Maintains a cache of files on disk.

Author:
Neil W. Weber

Field Summary
protected  File cacheDir
          The local directory holding the cached files.
 
Constructor Summary
JvFileCache(String dir)
          Construct a new JvFileCache using the given directory as the local cache directory.
 
Method Summary
 File get(URL url, JvDataTransferModel transferModel)
          Get the file at the given URL.
static void main(String[] args)
           
 void setCacheDir(String dirname)
          Set the name of the directory to store the cached files
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheDir

protected File cacheDir
The local directory holding the cached files.

Constructor Detail

JvFileCache

public JvFileCache(String dir)
            throws IOException
Construct a new JvFileCache using the given directory as the local cache directory.

Parameters:
dir - the name of the directory to store the cached files
Throws:
IOException
Method Detail

setCacheDir

public void setCacheDir(String dirname)
                 throws IOException
Set the name of the directory to store the cached files

Parameters:
dirname - the name of the cache directory
Throws:
IOException

get

public File get(URL url,
                JvDataTransferModel transferModel)
         throws IOException
Get the file at the given URL. If the file is already in the cache, use it. Otherwise, download the file and store it in the cache.

Parameters:
url - the URL of the desired file
transferModel - model containing the state of the transfer
Returns:
the downloaded file
Throws:
IOException

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 1999-2004 Neil W. Weber. All Rights Reserved.