MultipartDataSource (JavaMail API documentation)
Date: 2019-08-31

javax.mail

## Interface MultipartDataSource

- All Superinterfaces:
    javax.activation.DataSource

      public interface MultipartDataSource
      extends javax.activation.DataSource

  MultipartDataSource is a `DataSource` that contains body parts. This allows "mail aware" `DataContentHandlers` to be implemented more efficiently by being aware of such `DataSources` and using the appropriate methods to access `BodyParts`.

  Note that the data of a MultipartDataSource is also available as an input stream.

  This interface will typically be implemented by providers that preparse multipart bodies, for example an IMAP provider.

  See Also:
    `DataSource`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `BodyPart` | `getBodyPart(int index)` Get the specified Part.
    `int` | `getCount()` Return the number of enclosed BodyPart objects.

    - ### Methods inherited from interface javax.activation.DataSource

      `getContentType, getInputStream, getName, getOutputStream`

- - ### Method Detail

    - #### getCount

          int getCount()

      Return the number of enclosed BodyPart objects.
      Returns:
        number of parts

    - #### getBodyPart

          BodyPart getBodyPart(int index)
                        throws MessagingException

      Get the specified Part. Parts are numbered starting at 0.
      Parameters:
        `index` - the index of the desired Part
      Returns:
        the Part
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the given index is out of range.
        `MessagingException`

Copyright © 1996-2013, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms< /a>.