public class NamedOutputStream extends NamedCloseable
Constructor and Description |
---|
NamedOutputStream(java.lang.String name,
java.io.OutputStream stream)
Create a new instance with the given name associated to the given output stream.
|
Modifier and Type | Method and Description |
---|---|
protected java.io.Closeable |
getCloseable()
Returns the closeable that is associated with the name defined in this class.
|
java.io.OutputStream |
getOutputStream()
Returns the underlying OutputStream (will never be null).
|
static NamedOutputStream |
open(java.io.File file)
Opens the provided file and returns the output stream along with the file name.
|
static NamedOutputStream |
open(java.lang.String filename)
Opens the file specified by the given filename and returns the output stream along with the file name.
|
close, getName, setName
public NamedOutputStream(java.lang.String name, java.io.OutputStream stream)
name
- The name of the output stream (must not be null).stream
- The output stream to be associated with the name (must not be null).java.lang.IllegalArgumentException
- If either name or stream is null.public static NamedOutputStream open(java.io.File file) throws java.io.FileNotFoundException
file
- The file to be opened (must not be null).java.io.FileNotFoundException
- If the provided file cannot be created/opened.public static NamedOutputStream open(java.lang.String filename) throws java.io.FileNotFoundException
filename
- The file to be opened (must not be null).java.io.FileNotFoundException
- If a file with the given name cannot be created/opened.public java.io.OutputStream getOutputStream()
protected java.io.Closeable getCloseable()
NamedCloseable
getCloseable
in class NamedCloseable