Class ByteArrayDataSource

java.lang.Object
com.randomnoun.common.email.ByteArrayDataSource
All Implemented Interfaces:
jakarta.activation.DataSource

public class ByteArrayDataSource extends Object implements jakarta.activation.DataSource
A DataSource generated from an array of bytes Used to send arbitrary data through the JavaMail API
Author:
knoxg
  • Constructor Details

    • ByteArrayDataSource

      public ByteArrayDataSource(byte[] data, String name, String contentType)
      Creates a DataSource from an array of bytes
      Parameters:
      data - byte[] Array of bytes to convert into a DataSource
      name - String Name of the DataSource (ex: filename)
  • Method Details

    • getName

      public String getName()
      Returns the name of the DataSource
      Specified by:
      getName in interface jakarta.activation.DataSource
      Returns:
      String Name of the DataSource
    • getContentType

      Returns the content type of the DataSource
      Specified by:
      getContentType in interface jakarta.activation.DataSource
      Returns:
      String Content type of the DataSource
    • getInputStream

      Returns an InputStream from the DataSource
      Specified by:
      getInputStream in interface jakarta.activation.DataSource
      Returns:
      InputStream Array of bytes converted into an InputStream
      Throws:
      IOException
    • getOutputStream

      Returns an OutputStream from the DataSource
      Specified by:
      getOutputStream in interface jakarta.activation.DataSource
      Returns:
      OutputStream Array of bytes converted into an OutputStream
      Throws:
      IOException