Class FileSerializer

  • All Implemented Interfaces:
    Serializer<java.io.File>

    public class FileSerializer
    extends java.lang.Object
    implements Serializer<java.io.File>
    Implementation of the Serializer interface that reads and writes File objects.
    • 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.String getMIMEType​(java.io.File file)
      Returns the MIME type of the data read and written by this serializer.
      java.io.File readObject​(java.io.InputStream inputStream)
      Reads a file from an input stream.
      void writeObject​(java.io.File file, java.io.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
    • 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 be null to use the system default location).
    • Method Detail

      • readObject

        public java.io.File readObject​(java.io.InputStream inputStream)
                                throws java.io.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<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,
                                SerializationException
        Writes a file to an output stream.
        Specified by:
        writeObject in interface Serializer<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: Serializer
        Returns the MIME type of the data read and written by this serializer.
        Specified by:
        getMIMEType in interface Serializer<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. If null, the base MIME type is returned.
        Returns:
        The MIME type of the current data.