org.apache.pivot.io
Class FileSerializer

java.lang.Object
  extended by org.apache.pivot.io.FileSerializer
All Implemented Interfaces:
Serializer<File>

public class FileSerializer
extends Object
implements Serializer<File>

Implementation of the Serializer interface that reads and writes File objects.


Field Summary
static int BUFFER_SIZE
           
 
Constructor Summary
FileSerializer()
          Creates a new file serializer that will store temporary files in the default temporary file directory.
FileSerializer(File tempFileDirectory)
          Creates a new file serializer that will store temporary files in a specific directory.
 
Method Summary
 String getMIMEType(File file)
          Returns the MIME type of the data read and written by this serializer.
 File readObject(InputStream inputStream)
          Reads a file from an input stream.
 void writeObject(File file, OutputStream outputStream)
          Writes a file to an output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

FileSerializer

public FileSerializer()
Creates a new file serializer that will store temporary files in the default temporary file directory.


FileSerializer

public FileSerializer(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 folders.
Method Detail

readObject

public File readObject(InputStream inputStream)
                throws IOException,
                       SerializationException
Reads a file from an input stream. The returned file is a temporary file and must be deleted by the caller.

Specified by:
readObject in interface Serializer<File>
Parameters:
inputStream - The data stream from which the object will be read.
Returns:
The deserialized object.
Throws:
IOException
SerializationException

writeObject

public void writeObject(File file,
                        OutputStream outputStream)
                 throws IOException,
                        SerializationException
Writes a file to an output stream.

Specified by:
writeObject in interface Serializer<File>
Parameters:
file - The object to serialize.
outputStream - The data stream to which the object will be written.
Throws:
IOException
SerializationException

getMIMEType

public String getMIMEType(File file)
Description copied from interface: Serializer
Returns the MIME type of the data read and written by this serializer.

Specified by:
getMIMEType in interface Serializer<File>
Parameters:
file - If provided, allows the serializer to attach parameters to the returned MIME type containing more detailed information about the data. If null, the base MIME type is returned.