org.apache.tools.ant.util
Class LazyFileOutputStream
OutputStream
org.apache.tools.ant.util.LazyFileOutputStream
public class LazyFileOutputStream
extends OutputStream
Class that delays opening the output file until the first bytes
shall be written or the method
open
has been invoked
explicitly.
LazyFileOutputStream(File f) - Creates 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.
|
void | close() - Close the file.
|
void | open() - Explicitly open the file for writing.
|
void | write(byte[] b) - Delegates to the three-arg version.
|
void | write(byte[] b, int offset, int len) - Write part of a byte array.
|
void | write(int b) - Write a byte.
|
LazyFileOutputStream
public LazyFileOutputStream(File f)
Creates a stream that will eventually write to the file with
the given name and replace it.
LazyFileOutputStream
public 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.
file
- the file to create.append
- if true append rather than replace.
LazyFileOutputStream
public 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).
file
- the file to create.append
- if true append rather than replace.alwaysCreate
- if true create the file even if nothing to write.
LazyFileOutputStream
public LazyFileOutputStream(String name)
Creates a stream that will eventually write to the file with
the given name and replace it.
LazyFileOutputStream
public 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.
name
- the filename.append
- if true append rather than replace.
close
public void close()
throws IOException
Close the file.
open
public void open()
throws IOException
Explicitly open the file for writing.
Returns silently if the file has already been opened.
write
public void write(byte[] b)
throws IOException
Delegates to the three-arg version.
b
- the bytearray to write.
write
public void write(byte[] b,
int offset,
int len)
throws IOException
Write part of a byte array.
b
- the byte array.offset
- write from this index.len
- the number of bytes to write.
write
public void write(int b)
throws IOException
Write a byte.