org.apache.jackrabbit.core.data.db
Class TempFileInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.commons.io.input.ProxyInputStream
org.apache.commons.io.input.AutoCloseInputStream
org.apache.jackrabbit.core.data.db.TempFileInputStream
- All Implemented Interfaces:
- Closeable
public class TempFileInputStream
- extends org.apache.commons.io.input.AutoCloseInputStream
An input stream from a temporary file. The file is deleted when the stream is
closed, fully read, or garbage collected.
This class does not support mark/reset. It is always to be wrapped
using a BufferedInputStream.
|
Constructor Summary |
TempFileInputStream(File file,
boolean delayedResourceCleanup)
Construct a new temporary file input stream. |
| Methods inherited from class org.apache.commons.io.input.AutoCloseInputStream |
afterRead, finalize |
| Methods inherited from class org.apache.commons.io.input.ProxyInputStream |
beforeRead, handleIOException |
TempFileInputStream
public TempFileInputStream(File file,
boolean delayedResourceCleanup)
throws FileNotFoundException
- Construct a new temporary file input stream.
The file is deleted if the input stream is closed or fully read and
delayedResourceCleanup was set to true. Otherwise you must call
deleteFile().
Deleting is only attempted once.
- Parameters:
file - the temporary filedelayedResourceCleanup -
- Throws:
FileNotFoundException
writeToFileAndClose
public static long writeToFileAndClose(InputStream in,
File file)
throws IOException
- Copy the data to a file and close the input stream afterwards.
- Parameters:
in - the input streamfile - the target file
- Returns:
- the size of the file
- Throws:
IOException
getFile
public File getFile()
deleteFile
public void deleteFile()
close
public void close()
throws IOException
- Specified by:
close in interface Closeable- Overrides:
close in class org.apache.commons.io.input.AutoCloseInputStream
- Throws:
IOException
available
public int available()
throws IOException
- Overrides:
available in class org.apache.commons.io.input.ProxyInputStream
- Throws:
IOException
mark
public void mark(int readlimit)
- This method does nothing.
- Overrides:
mark in class org.apache.commons.io.input.ProxyInputStream
markSupported
public boolean markSupported()
- Check whether mark and reset are supported.
- Overrides:
markSupported in class org.apache.commons.io.input.ProxyInputStream
- Returns:
- false
skip
public long skip(long n)
throws IOException
- Overrides:
skip in class org.apache.commons.io.input.ProxyInputStream
- Throws:
IOException
reset
public void reset()
throws IOException
- Overrides:
reset in class org.apache.commons.io.input.ProxyInputStream
- Throws:
IOException
read
public int read(byte[] b,
int off,
int len)
throws IOException
- Overrides:
read in class org.apache.commons.io.input.ProxyInputStream
- Throws:
IOException
read
public int read(byte[] b)
throws IOException
- Overrides:
read in class org.apache.commons.io.input.ProxyInputStream
- Throws:
IOException
read
public int read()
throws IOException
- Overrides:
read in class org.apache.commons.io.input.ProxyInputStream
- Throws:
IOException
Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.