Package org.apache.tools.ant.util
Class LazyFileOutputStream
- java.lang.Object
- 
- java.io.OutputStream
- 
- org.apache.tools.ant.util.LazyFileOutputStream
 
 
- 
- All Implemented Interfaces:
- java.io.Closeable,- java.io.Flushable,- java.lang.AutoCloseable
 
 public class LazyFileOutputStream extends java.io.OutputStreamClass that delays opening the output file until the first bytes shall be written or the methodopenhas been invoked explicitly.- Since:
- Ant 1.6
 
- 
- 
Constructor SummaryConstructors Constructor Description LazyFileOutputStream(java.io.File f)Creates a stream that will eventually write to the file with the given name and replace it.LazyFileOutputStream(java.io.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(java.io.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(java.lang.String name)Creates a stream that will eventually write to the file with the given name and replace it.LazyFileOutputStream(java.lang.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.
 
- 
- 
- 
Constructor Detail- 
LazyFileOutputStreampublic LazyFileOutputStream(java.lang.String name) Creates a stream that will eventually write to the file with the given name and replace it.- Parameters:
- name- the filename.
 
 - 
LazyFileOutputStreampublic LazyFileOutputStream(java.lang.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.- Parameters:
- name- the filename.
- append- if true append rather than replace.
 
 - 
LazyFileOutputStreampublic LazyFileOutputStream(java.io.File f) Creates a stream that will eventually write to the file with the given name and replace it.- Parameters:
- f- the file to create.
 
 - 
LazyFileOutputStreampublic LazyFileOutputStream(java.io.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.- Parameters:
- file- the file to create.
- append- if true append rather than replace.
 
 - 
LazyFileOutputStreampublic LazyFileOutputStream(java.io.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).- 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 Detail- 
openpublic void open() throws java.io.IOExceptionExplicitly open the file for writing.Returns silently if the file has already been opened. - Throws:
- java.io.IOException- if there is an error.
 
 - 
closepublic void close() throws java.io.IOExceptionClose the file.- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- java.io.Closeable
- Overrides:
- closein class- java.io.OutputStream
- Throws:
- java.io.IOException- if there is an error.
 
 - 
writepublic void write(byte[] b) throws java.io.IOExceptionDelegates to the three-arg version.- Overrides:
- writein class- java.io.OutputStream
- Parameters:
- b- the bytearray to write.
- Throws:
- java.io.IOException- if there is a problem.
 
 - 
writepublic void write(byte[] b, int offset, int len) throws java.io.IOExceptionWrite part of a byte array.- Overrides:
- writein class- java.io.OutputStream
- Parameters:
- b- the byte array.
- offset- write from this index.
- len- the number of bytes to write.
- Throws:
- java.io.IOException- if there is a problem.
 
 - 
writepublic void write(int b) throws java.io.IOExceptionWrite a byte.- Specified by:
- writein class- java.io.OutputStream
- Parameters:
- b- the byte to write.
- Throws:
- java.io.IOException- if there is a problem.
 
 
- 
 
-