org.apache.jackrabbit.core.data.db
Class TempFileInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.apache.commons.io.input.ProxyInputStream
              extended by org.apache.commons.io.input.AutoCloseInputStream
                  extended by 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.


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
TempFileInputStream(File file)
          Construct a new temporary file input stream.
 
Method Summary
 int available()
           
 void close()
           
 void mark(int readlimit)
          This method does nothing.
 boolean markSupported()
          Check whether mark and reset are supported.
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void reset()
           
 long skip(long n)
           
static long writeToFileAndClose(InputStream in, File file)
          Copy the data to a file and close the input stream afterwards.
 
Methods inherited from class org.apache.commons.io.input.AutoCloseInputStream
finalize
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TempFileInputStream

public TempFileInputStream(File file)
                    throws FileNotFoundException
Construct a new temporary file input stream. The file is deleted if the input stream is closed or fully read. Deleting is only attempted once.

Parameters:
file - the temporary file
Throws:
FileNotFoundException
Method Detail

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 stream
file - the target file
Returns:
the size of the file
Throws:
IOException

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.AutoCloseInputStream
Throws:
IOException

read

public int read(byte[] b)
         throws IOException
Overrides:
read in class org.apache.commons.io.input.AutoCloseInputStream
Throws:
IOException

read

public int read()
         throws IOException
Overrides:
read in class org.apache.commons.io.input.AutoCloseInputStream
Throws:
IOException


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.