Top Description Fields Constructors Methods
org.apache.tools.ant.util

public Class LazyFileOutputStream

extends OutputStream
Class Inheritance
Imports
java.io.File, .IOException, .OutputStream, org.apache.tools.ant.util.FileUtils

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

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private boolean
private File
private OutputStream
private boolean

Constructor Summary

AccessConstructor and Description
public
LazyFileOutputStream(String
the filename.
name
)

Creates a stream that will eventually write to the file with the given name and replace it.

public
LazyFileOutputStream(String
the filename.
name
,
boolean
if true append rather than replace.
append
)

Creates a stream that will eventually write to the file with the given name and optionally append to instead of replacing it.

public
LazyFileOutputStream(File
the file to create.
f
)

Creates a stream that will eventually write to the file with the given name and replace it.

public
LazyFileOutputStream(File
the file to create.
file
,
boolean
if true append rather than replace.
append
)

Creates a stream that will eventually write to the file with the given name and optionally append to instead of replacing it.

public
LazyFileOutputStream(File
the file to create.
file
,
boolean
if true append rather than replace.
append
,
boolean
if true create the file even if nothing to write.
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).

Method Summary

Modifier and TypeMethod and Description
public synchronized void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Close the file.
private synchronized void
public void
open()

Explicitly open the file for writing.

public void
write(byte[]
the bytearray to write.
b
)

Overrides java.io.OutputStream.write.

Delegates to the three-arg version.
public synchronized void
write(byte[]
the byte array.
b
,
int
write from this index.
offset
,
int
the number of bytes to write.
len
)

Overrides java.io.OutputStream.write.

Write part of a byte array.
public synchronized void
write(int
the byte to write.
b
)

Implements abstract java.io.OutputStream.write.

Write a byte.
Inherited from java.io.OutputStream:
flushnullOutputStream

Field Detail

alwaysCreateback to summary
private boolean alwaysCreate
appendback to summary
private boolean append
closedback to summary
private boolean closed
fileback to summary
private File file
fosback to summary
private OutputStream fos
openedback to summary
private boolean opened

Constructor Detail

LazyFileOutputStreamback to summary
public LazyFileOutputStream(String name)

Creates a stream that will eventually write to the file with the given name and replace it.

Parameters
name:String

the filename.

LazyFileOutputStreamback to summary
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.

Parameters
name:String

the filename.

append:boolean

if true append rather than replace.

LazyFileOutputStreamback to summary
public LazyFileOutputStream(File f)

Creates a stream that will eventually write to the file with the given name and replace it.

Parameters
f:File

the file to create.

LazyFileOutputStreamback to summary
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.

Parameters
file:File

the file to create.

append:boolean

if true append rather than replace.

LazyFileOutputStreamback to summary
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).

Parameters
file:File

the file to create.

append:boolean

if true append rather than replace.

alwaysCreate:boolean

if true create the file even if nothing to write.

Method Detail

closeback to summary
public synchronized void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Close the file.

Annotations
@Override
Exceptions
IOException:
if there is an error.
ensureOpenedback to summary
private synchronized void ensureOpened() throws IOException
openback to summary
public void open() throws IOException

Explicitly open the file for writing.

Returns silently if the file has already been opened.

Exceptions
IOException:
if there is an error.
writeback to summary
public void write(byte[] b) throws IOException

Overrides java.io.OutputStream.write.

Delegates to the three-arg version.

Parameters
b:byte[]

the bytearray to write.

Annotations
@Override
Exceptions
IOException:
if there is a problem.
writeback to summary
public synchronized void write(byte[] b, int offset, int len) throws IOException

Overrides java.io.OutputStream.write.

Write part of a byte array.

Parameters
b:byte[]

the byte array.

offset:int

write from this index.

len:int

the number of bytes to write.

Annotations
@Override
Exceptions
IOException:
if there is a problem.
writeback to summary
public synchronized void write(int b) throws IOException

Implements abstract java.io.OutputStream.write.

Write a byte.

Parameters
b:int

the byte to write.

Annotations
@Override
Exceptions
IOException:
if there is a problem.