Package org.frankframework.stream
Class SerializableFileReference
java.lang.Object
org.frankframework.stream.SerializableFileReference
- All Implemented Interfaces:
Serializable
,AutoCloseable
A reference to a file
Path
that can be serialized. When serialized it will write all the file data to
the serialization stream.
When deserialized, it will copy all file-data to a new temporary file.- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSerializableFileReference
(String charset, Path path) Create a character-dataSerializableFileReference
for the file at given path.SerializableFileReference
(Path path, boolean deleteOnClose) Create a binarySerializableFileReference
for the file at given path. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
getPath()
long
getSize()
boolean
isBinary()
static SerializableFileReference
of
(byte[] data) Create a newSerializableFileReference
from the givenbyte[]
.static SerializableFileReference
of
(InputStream in) Create a newSerializableFileReference
from the givenInputStream
.static SerializableFileReference
Create a newSerializableFileReference
from the givenReader
.static SerializableFileReference
Create a newSerializableFileReference
from the givenString
.
-
Field Details
-
TEMP_MESSAGE_DIRECTORY
- See Also:
-
-
Constructor Details
-
SerializableFileReference
Create a binarySerializableFileReference
for the file at given path. -
SerializableFileReference
Create a character-dataSerializableFileReference
for the file at given path.The file will be not deleted on calling
close()
.- Parameters:
charset
- Character set to be used when reading the file.path
-Path
to the file being referenced.
-
-
Method Details
-
of
Create a newSerializableFileReference
from the givenInputStream
. TheInputStream
will be copied to a temporary file on disk and will be closed afterward. TheSerializableFileReference
will be treated as binary data.The temporary file will be deleted on calling
close()
.- Parameters:
in
- TheInputStream
from which to create theSerializableFileReference
. Will be closed after completion of this method.- Returns:
- A new binary
SerializableFileReference
. - Throws:
IOException
- If theInputStream
cannot be read or a temporary file cannot be created / written to.
-
of
Create a newSerializableFileReference
from the givenbyte[]
. Thebyte[]
will be copied to a temporary file on disk. TheSerializableFileReference
will be treated as binary data.The temporary file will be deleted on calling
close()
.- Parameters:
data
- Thebyte[]
from which to create theSerializableFileReference
.- Returns:
- A new binary
SerializableFileReference
. - Throws:
IOException
- If thebyte[]
cannot be written to a temporary file.
-
of
Create a newSerializableFileReference
from the givenReader
. TheReader
will be copied to a temporary file on disk and will be closed afterward. TheSerializableFileReference
will be treated as character data.The temporary file will be deleted on calling
close()
.- Parameters:
in
- TheReader
from which to create theSerializableFileReference
. Will be closed after completion of this method.charset
- Character set of the data in theReader
.- Returns:
- A new character-data
SerializableFileReference
. - Throws:
IOException
- If theReader
cannot be read or a temporary file cannot be created / written to.
-
of
Create a newSerializableFileReference
from the givenString
. TheString
will be copied to a temporary file on disk. TheSerializableFileReference
will be treated as character data.The temporary file will be deleted on calling
close()
.- Parameters:
data
- TheString
from which to create theSerializableFileReference
.charset
- Character used for writing out and reading back the data.- Returns:
- A new character-data
SerializableFileReference
. - Throws:
IOException
- If theString
data cannot be written to a temporary file.
-
getSize
public long getSize() -
getReader
- Throws:
IOException
-
getInputStream
- Throws:
IOException
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
isBinary
public boolean isBinary() -
getPath
-