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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSerializableFileReference(Path path, boolean deleteOnClose) Create a binarySerializableFileReferencefor the file at given path. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()longgetSize()static SerializableFileReferenceof(byte[] data) Create a newSerializableFileReferencefrom the givenbyte[].static SerializableFileReferenceof(InputStream in) Create a newSerializableFileReferencefrom the givenInputStream.static SerializableFileReferenceCreate a newSerializableFileReferencefrom the givenReader.static SerializableFileReferenceCreate a newSerializableFileReferencefrom the givenString.
-
Field Details
-
TEMP_MESSAGE_DIRECTORY
- See Also:
-
-
Constructor Details
-
Method Details
-
of
Create a newSerializableFileReferencefrom the givenInputStream. TheInputStreamwill be copied to a temporary file on disk and will be closed afterward. TheSerializableFileReferencewill be treated as binary data.The temporary file will be deleted on calling
close().- Parameters:
in- TheInputStreamfrom which to create theSerializableFileReference. Will be closed after completion of this method.- Returns:
- A new binary
SerializableFileReference. - Throws:
IOException- If theInputStreamcannot be read or a temporary file cannot be created / written to.
-
of
Create a newSerializableFileReferencefrom the givenbyte[]. Thebyte[]will be copied to a temporary file on disk. TheSerializableFileReferencewill 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 newSerializableFileReferencefrom the givenReader. TheReaderwill be copied to a temporary file on disk and will be closed afterward. TheSerializableFileReferencewill be treated as character data.The temporary file will be deleted on calling
close().- Parameters:
in- TheReaderfrom 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 theReadercannot be read or a temporary file cannot be created / written to.
-
of
Create a newSerializableFileReferencefrom the givenString. TheStringwill be copied to a temporary file on disk. TheSerializableFileReferencewill be treated as character data.The temporary file will be deleted on calling
close().- Parameters:
data- TheStringfrom which to create theSerializableFileReference.charset- Character used for writing out and reading back the data.- Returns:
- A new character-data
SerializableFileReference. - Throws:
IOException- If theStringdata cannot be written to a temporary file.
-
getSize
public long getSize() -
getReader
- Throws:
IOException
-
getInputStream
- Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-