CodeBeamer 5.4.0.1-RC API

com.intland.codebeamer.utils
Class AutoClosingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.intland.codebeamer.utils.AutoClosingInputStream
All Implemented Interfaces:
java.io.Closeable

public class AutoClosingInputStream
extends java.io.FilterInputStream

Inputstream class that prevents from leaving the stream open: it tries to close the embedded stream immediately when the read operation returns with EOF.


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
AutoClosingInputStream(java.io.File file, boolean deleteOnClosed)
           
AutoClosingInputStream(java.io.InputStream inputStream)
          Read a stream
 
Method Summary
 int available()
           
 void close()
           
protected  void ensureFileOpen()
          opens the stream if not open.
protected  void finalize()
          Overridden to close/drop the file on gc()
 void mark(int readlimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int l)
           
 void reset()
           
 void setOnDeleteFailed(org.apache.commons.collections.Closure onDeleteFailed)
          Set the callback method (Closure) will be called if the deletion of this file has failed.
 long skip(long n)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoClosingInputStream

public AutoClosingInputStream(java.io.File file,
                              boolean deleteOnClosed)
                       throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

AutoClosingInputStream

public AutoClosingInputStream(java.io.InputStream inputStream)
Read a stream

Parameters:
inputStream -
Method Detail

ensureFileOpen

protected void ensureFileOpen()
                       throws java.io.FileNotFoundException
opens the stream if not open. It is assured that a new stream will be opened during the first read operation.

Throws:
java.io.FileNotFoundException

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int l)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterInputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.FilterInputStream
Throws:
java.io.IOException

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class java.io.FilterInputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.FilterInputStream

mark

public void mark(int readlimit)
Overrides:
mark in class java.io.FilterInputStream

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.FilterInputStream
Throws:
java.io.IOException

finalize

protected void finalize()
                 throws java.lang.Throwable
Overridden to close/drop the file on gc()

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

setOnDeleteFailed

public void setOnDeleteFailed(org.apache.commons.collections.Closure onDeleteFailed)
Set the callback method (Closure) will be called if the deletion of this file has failed.

Parameters:
onDeleteFailed - the onDeleteFailed to set

CodeBeamer 5.4.0.1-RC API

Copyright © 2006-2009 Intland Software. All rights reserved.