Package org.apache.tools.ant.util
Class LazyFileOutputStream
java.lang.Object
java.io.OutputStream
org.apache.tools.ant.util.LazyFileOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Class that delays opening the output file until the first bytes
shall be written or the method
open has been invoked
explicitly.- Since:
- Ant 1.6
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a stream that will eventually write to the file with the given name and replace it.LazyFileOutputStream(File file, boolean append) Creates a stream that will eventually write to the file with the given name and optionally append to instead of replacing it.LazyFileOutputStream(File file, boolean append, boolean alwaysCreate) Creates a stream that will eventually write to the file with the given name, optionally append to instead of replacing it, and optionally always create a file (even if zero length).LazyFileOutputStream(String name) Creates a stream that will eventually write to the file with the given name and replace it.LazyFileOutputStream(String name, boolean append) Creates a stream that will eventually write to the file with the given name and optionally append to instead of replacing it. -
Method Summary
Methods inherited from class java.io.OutputStream
flush, nullOutputStream
-
Constructor Details
-
LazyFileOutputStream
Creates a stream that will eventually write to the file with the given name and replace it.- Parameters:
name- the filename.
-
LazyFileOutputStream
Creates a stream that will eventually write to the file with the given name and optionally append to instead of replacing it.- Parameters:
name- the filename.append- if true append rather than replace.
-
LazyFileOutputStream
Creates a stream that will eventually write to the file with the given name and replace it.- Parameters:
f- the file to create.
-
LazyFileOutputStream
Creates a stream that will eventually write to the file with the given name and optionally append to instead of replacing it.- Parameters:
file- the file to create.append- if true append rather than replace.
-
LazyFileOutputStream
Creates a stream that will eventually write to the file with the given name, optionally append to instead of replacing it, and optionally always create a file (even if zero length).- Parameters:
file- the file to create.append- if true append rather than replace.alwaysCreate- if true create the file even if nothing to write.
-
-
Method Details
-
open
Explicitly open the file for writing.Returns silently if the file has already been opened.
- Throws:
IOException- if there is an error.
-
close
Close the file.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- if there is an error.
-
write
Delegates to the three-arg version.- Overrides:
writein classOutputStream- Parameters:
b- the bytearray to write.- Throws:
IOException- if there is a problem.
-
write
Write part of a byte array.- Overrides:
writein classOutputStream- Parameters:
b- the byte array.offset- write from this index.len- the number of bytes to write.- Throws:
IOException- if there is a problem.
-
write
Write a byte.- Specified by:
writein classOutputStream- Parameters:
b- the byte to write.- Throws:
IOException- if there is a problem.
-