phelps.io

Class InputStreamCached

public class InputStreamCached extends FilterInputStream

Incrementally caches data to a cache file as it streams. If the data is needed as a random-access file, rather than a stream, getFile reads all the data from the stream to disk (if not already cached), then returns a handle to the cached location. This class is a low-level data mover, underneath a cache management policy that determines whether already cached and if so whether to refresh, and the path for the cache file.

Version: $Revision: 1.2 $ $Date: 2002/10/24 21:21:33 $

Constructor Summary
InputStreamCached(InputStream in, File infile, File cacheto)
Read from in and write to cacheto.
Method Summary
voidcancel()
Cancel: terminate gracefully by closing streams and delete any incomplete cache file.
voidclose()
Open a stream from the file, which can easily be Provides a uniform interface to local files as to network URIs.
FilegetFile()
Read all data from stream into a file, close both input and file-writing streams, then return the file.
intread()
intread(byte[] b, int off, int len)
StringtoString()

Constructor Detail

InputStreamCached

public InputStreamCached(InputStream in, File infile, File cacheto)
Read from in and write to cacheto. Simple byte copier; cacheing policies to be performed by client.

Method Detail

cancel

public void cancel()
Cancel: terminate gracefully by closing streams and delete any incomplete cache file.

close

public void close()
Open a stream from the file, which can easily be Provides a uniform interface to local files as to network URIs. public InputStreamCached(File file) throws FileNotFoundException { //super(new BufferedInputStream(new FileInputStream(file), 8*1024)); // wrapping in BufferedInputStream client option assert file!=null; outfile_ = file; System.out.println(" in = out = "+outfile_); out_ = null; }

getFile

public File getFile()
Read all data from stream into a file, close both input and file-writing streams, then return the file.

read

public int read()

read

public int read(byte[] b, int off, int len)

toString

public String toString()