public class DataFileTarget extends Object implements DataTarget
A DataTarget
implementation based on a file.
Constructor and Description |
---|
DataFileTarget(File file)
Creates a source.
|
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 DataFileTarget(File file)
Creates a source.
The stream on the file will be opened the first time the
getOutputStream()
method is called.
file
- The file.IllegalArgumentException
- If the file is 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.