public class DataStreamTarget extends Object implements DataTarget
A DataTarget
implementation based on a stream.
Constructor and Description |
---|
DataStreamTarget(OutputStream out,
String name,
boolean closeable)
Creates a target.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
String |
getName()
Returns the name of the source.
|
OutputStream |
getOutputStream()
Returns a stream for writing the data.
|
public DataStreamTarget(OutputStream out, String name, boolean closeable)
Creates a target.
out
- The stream.name
- The name of the source.closeable
- The flag if the close()
method will close the stream.IllegalArgumentException
- If any of the parameters are null
.public String getName()
DataTarget
Returns the name of the source.
This name is used e.g. for detail messages of exceptions.
getName
in interface DataTarget
public OutputStream getOutputStream() throws IOException
DataTarget
Returns a stream for writing the data.
The method will always return the same OutputStream
if the source
is still open. If the OutputStream.close()
method is called the
source will behave the same as the Closeable.close()
method was called.
getOutputStream
in interface DataTarget
IOException
- If an I/O error occurs.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2015–2019. All rights reserved.