|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
org.apache.avalon.fortress.tools.ChangedFileOutputStream
public final class ChangedFileOutputStream
OutputStream which will only update an existing file if its contents actually change. Needed to keep Ant from rebuilding jars even when nothing has changed.
Field Summary | |
---|---|
private java.io.ByteArrayOutputStream |
m_bos
The output stream used to buffer data being writen. |
private java.io.File |
m_file
The file to write to. |
Constructor Summary | |
---|---|
ChangedFileOutputStream(java.io.File file)
Creates a new ChangedFileOutputStream. |
Method Summary | |
---|---|
void |
close()
Close the stream. |
private byte[] |
readBytes(java.io.File file)
Reads the full contents of a file into a byte array. |
void |
write(int b)
Writes the specified byte to this output stream. |
private void |
writeBytes(java.io.File file,
byte[] bytes)
Reads the full contents of a byte array out to a file. |
Methods inherited from class java.io.OutputStream |
---|
flush, write, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.io.File m_file
private java.io.ByteArrayOutputStream m_bos
Constructor Detail |
---|
public ChangedFileOutputStream(java.io.File file)
file
- The file to write to.Method Detail |
---|
public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
b
- Byte to write.
java.io.IOException
- If an I/O error occurs.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.OutputStream
java.io.IOException
- If an I/O error occurs.private byte[] readBytes(java.io.File file) throws java.io.IOException
file
- File to read.
java.io.IOException
- If the file could not be read for any reason.private void writeBytes(java.io.File file, byte[] bytes) throws java.io.IOException
file
- File to write to.bytes
- The binary data to write.
java.io.IOException
- If the file could not be written to for any reason.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |