Package org.apache.pivot.io
Class FileSerializer
- java.lang.Object
-
- org.apache.pivot.io.FileSerializer
-
- All Implemented Interfaces:
Serializer<java.io.File>
public class FileSerializer extends java.lang.Object implements Serializer<java.io.File>
Implementation of theSerializerinterface that reads and writesFileobjects.
-
-
Constructor Summary
Constructors Constructor Description FileSerializer()Creates a new file serializer that will store temporary files in the default temporary file directory.FileSerializer(java.io.File tempFileDirectory)Creates a new file serializer that will store temporary files in a specific directory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetMIMEType(java.io.File file)Returns the MIME type of the data read and written by this serializer.java.io.FilereadObject(java.io.InputStream inputStream)Reads a file from an input stream.voidwriteObject(java.io.File file, java.io.OutputStream outputStream)Writes a file to an output stream.
-
-
-
Constructor Detail
-
FileSerializer
public FileSerializer()
Creates a new file serializer that will store temporary files in the default temporary file directory.
-
FileSerializer
public FileSerializer(java.io.File tempFileDirectory)
Creates a new file serializer that will store temporary files in a specific directory.- Parameters:
tempFileDirectory- The directory in which to store temporary files (can benullto use the system default location).
-
-
Method Detail
-
readObject
public java.io.File readObject(java.io.InputStream inputStream) throws java.io.IOException, SerializationExceptionReads a file from an input stream. The returned file is a temporary file and must be deleted by the caller.- Specified by:
readObjectin interfaceSerializer<java.io.File>- Parameters:
inputStream- The data stream from which the object will be read.- Returns:
- The deserialized object.
- Throws:
java.io.IOException- for any errors accessing or reading the object.SerializationException- for any formatting errors encountered while deserializing the object.
-
writeObject
public void writeObject(java.io.File file, java.io.OutputStream outputStream) throws java.io.IOException, SerializationExceptionWrites a file to an output stream.- Specified by:
writeObjectin interfaceSerializer<java.io.File>- Parameters:
file- The object to serialize.outputStream- The data stream to which the object will be written.- Throws:
java.io.IOException- for any errors accessing or reading the object.SerializationException- for any formatting errors encountered while deserializing the object.
-
getMIMEType
public java.lang.String getMIMEType(java.io.File file)
Description copied from interface:SerializerReturns the MIME type of the data read and written by this serializer.- Specified by:
getMIMETypein interfaceSerializer<java.io.File>- Parameters:
file- If provided, allows the serializer to attach parameters to the returned MIME type containing more detailed information about the data. Ifnull, the base MIME type is returned.- Returns:
- The MIME type of the current data.
-
-