Package org.apache.commons.mail

# Class ByteArrayDataSource

java.lang.Object
org.apache.commons.mail.ByteArrayDataSource

All Implemented Interfaces:
  `DataSource`

@Deprecated public class ByteArrayDataSource extends Object implements DataSource
Deprecated.
since 1.4, use `ByteArrayDataSource` or `SharedByteArrayInputStream`.
A typed DataSource for InputStream, byte array, and String.

From version 1.3.1, it is possible to set a name for this DataSource, and it is recommended to do so.

Since:
  1.0

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `BUFFER_SIZE`
  Deprecated.
  Define the buffer size.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ByteArrayDataSource(byte[] data, String contentType)`
  Deprecated.
  Constructs a new instance from a byte array.
  `ByteArrayDataSource(InputStream inputStream, String contentType)`
  Deprecated.
  Constructs a new instance from an input stream.
  `ByteArrayDataSource(String data, String contentType)`
  Deprecated.
  Constructs a new instance from a String.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getContentType()`
  Deprecated.
  Gets the content contentType.
  `InputStream`
  `getInputStream()`
  Deprecated.
  Gets the input stream.
  `String`
  `getName()`
  Deprecated.
  Gets the name.
  `OutputStream`
  `getOutputStream()`
  Deprecated.
  Gets the OutputStream to write to.
  `void`
  `setName(String name)`
  Deprecated.
  Sets the name for this DataSource.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### BUFFER_SIZE

    public static final int BUFFER_SIZE
    Deprecated.
    Define the buffer size.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### ByteArrayDataSource

    public ByteArrayDataSource(byte[] data, String contentType) throws IOException
    Deprecated.
    Constructs a new instance from a byte array.
    Parameters:
      `data` - A byte[].
      `contentType` - A String.
    Throws:
      `IOException` - IOException
    Since:
      1.0

  - ### ByteArrayDataSource

    public ByteArrayDataSource(InputStream inputStream, String contentType) throws IOException
    Deprecated.
    Constructs a new instance from an input stream.
    Parameters:
      `inputStream` - An InputStream.
      `contentType` - A String.
    Throws:
      `IOException` - IOException
    Since:
      1.0

  - ### ByteArrayDataSource

    public ByteArrayDataSource(String data, String contentType) throws IOException
    Deprecated.
    Constructs a new instance from a String. N.B. assumes the data string can be converted using the charset iso-8859-1.
    Parameters:
      `data` - A String.
      `contentType` - A String.
    Throws:
      `IOException` - IOException
    Since:
      1.0

- ## Method Details

  - ### getContentType

    public String getContentType()
    Deprecated.
    Gets the content contentType.
    Specified by:
      `getContentType` in interface `DataSource`
    Returns:
      A String.
    Since:
      1.0

  - ### getInputStream

    public InputStream getInputStream() throws IOException
    Deprecated.
    Gets the input stream.
    Specified by:
      `getInputStream` in interface `DataSource`
    Returns:
      An InputStream.
    Throws:
      `IOException` - IOException
    Since:
      1.0

  - ### getName

    public String getName()
    Deprecated.
    Gets the name.
    Specified by:
      `getName` in interface `DataSource`
    Returns:
      A String.
    Since:
      1.0

  - ### getOutputStream

    public OutputStream getOutputStream()
    Deprecated.
    Gets the OutputStream to write to.
    Specified by:
      `getOutputStream` in interface `DataSource`
    Returns:
      An OutputStream
    Since:
      1.0

  - ### setName

    public void setName(String name)
    Deprecated.
    Sets the name for this DataSource.
    Parameters:
      `name` - The name.
    Since:
      1.3.1