|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.OutputStream
org.jcoderz.commons.util.LazyFileOutputStream
public class LazyFileOutputStream
Purpose of this class is to avoid writing a File if it already exists and hold the same content.
This class in not about saving time for faster processing nor does is perform anything quicker. It sole checks if the target file exists, and if its content is already the same than the content that should be written. If this is the case no write operation is done at all. Therefore also the file content to be written is held in memory until the file is closed OR it is detected that the content did change.
Instances of this class are NOT multi thread save.
| Constructor Summary | |
|---|---|
LazyFileOutputStream(File file)
|
|
LazyFileOutputStream(File file,
boolean append)
|
|
LazyFileOutputStream(String name)
|
|
LazyFileOutputStream(String name,
boolean append)
|
|
| Method Summary | |
|---|---|
void |
close()
|
protected void |
finalize()
Cleans up the connection to the file, and ensures that the close method of this file output stream is
called when there are no more references to this stream. |
boolean |
isBuffered()
Returns true if the file is still buffered. |
void |
write(int b)
|
| Methods inherited from class java.io.OutputStream |
|---|
flush, write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LazyFileOutputStream(File file,
boolean append)
throws FileNotFoundException
FileNotFoundExceptionFileOutputStream.FileOutputStream(String, boolean)
public LazyFileOutputStream(File file)
throws FileNotFoundException
FileNotFoundExceptionFileOutputStream.FileOutputStream(File)
public LazyFileOutputStream(String name,
boolean append)
throws FileNotFoundException
FileNotFoundExceptionFileOutputStream.FileOutputStream(String, boolean)
public LazyFileOutputStream(String name)
throws FileNotFoundException
FileNotFoundExceptionFileOutputStream.FileOutputStream(String)| Method Detail |
|---|
public boolean isBuffered()
public void write(int b)
throws IOException
write in class OutputStreamIOException
public void close()
throws IOException
close in interface Closeableclose in class OutputStreamIOException
protected void finalize()
throws IOException,
Throwable
close method of this file output stream is
called when there are no more references to this stream.
finalize in class ObjectIOException - if an I/O error occurs.
ThrowableFileInputStream.close()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||