public class LazyFileOutputStream
extends java.io.OutputStream
open
has been invoked
explicitly.Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public LazyFileOutputStream(java.lang.String name)
name
- the filename.public LazyFileOutputStream(java.lang.String name, boolean append)
name
- the filename.append
- if true append rather than replace.public LazyFileOutputStream(java.io.File f)
f
- the file to create.public LazyFileOutputStream(java.io.File file, boolean append)
file
- the file to create.append
- if true append rather than replace.public LazyFileOutputStream(java.io.File file, boolean append, boolean alwaysCreate)
file
- the file to create.append
- if true append rather than replace.alwaysCreate
- if true create the file even if nothing to write.public void open() throws java.io.IOException
Returns silently if the file has already been opened.
java.io.IOException
- if there is an error.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
- if there is an error.public void write(byte[] b) throws java.io.IOException
write
in class java.io.OutputStream
b
- the bytearray to write.java.io.IOException
- if there is a problem.public void write(byte[] b, int offset, int len) throws java.io.IOException
write
in class java.io.OutputStream
b
- the byte array.offset
- write from this index.len
- the number of bytes to write.java.io.IOException
- if there is a problem.public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
b
- the byte to write.java.io.IOException
- if there is a problem.