Class BodyPartEntity

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class BodyPartEntity
    extends java.lang.Object
    implements java.io.Closeable
    Proxy class representing the entity of a BodyPart when a MultiPart entity is received and parsed.

    Its primary purpose is to provide an input stream to retrieve the actual data. However, it also transparently deals with storing the data in a temporary disk file, if it is larger than a configurable size; otherwise, the data is stored in memory for faster processing.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.File file  
      private static java.util.logging.Logger LOGGER  
      private org.jvnet.mimepull.MIMEPart mimePart  
    • Constructor Summary

      Constructors 
      Constructor Description
      BodyPartEntity​(org.jvnet.mimepull.MIMEPart mimePart)
      Constructs a new BodyPartEntity with a MIMEPart.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cleanup()
      Cleans up temporary file(s), if any were utilized.
      void close()
      Defers to cleanup().
      java.io.InputStream getInputStream()
      Gets the input stream of the raw bytes of this body part entity.
      void moveTo​(java.io.File file)
      Move the contents of the underlying InputStream or File to the given file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final java.util.logging.Logger LOGGER
      • mimePart

        private final org.jvnet.mimepull.MIMEPart mimePart
      • file

        private volatile java.io.File file
    • Constructor Detail

      • BodyPartEntity

        public BodyPartEntity​(org.jvnet.mimepull.MIMEPart mimePart)
        Constructs a new BodyPartEntity with a MIMEPart.
        Parameters:
        mimePart - MIMEPart containing the input stream of this body part entity.
    • Method Detail

      • getInputStream

        public java.io.InputStream getInputStream()
        Gets the input stream of the raw bytes of this body part entity.
        Returns:
        the input stream of the body part entity.
      • cleanup

        public void cleanup()
        Cleans up temporary file(s), if any were utilized.
      • close

        public void close()
                   throws java.io.IOException
        Defers to cleanup().
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • moveTo

        public void moveTo​(java.io.File file)
        Move the contents of the underlying InputStream or File to the given file.
        Parameters:
        file - destination file.