Class ByteArrayDataSource

java.lang.Object
org.compiere.util.ByteArrayDataSource
All Implemented Interfaces:
javax.activation.DataSource

public class ByteArrayDataSource extends Object implements javax.activation.DataSource
A DataSource based on the Java Mail Example.
This class implements a DataSource from:
  • an InputStream
  • a byte array
  • a String
  • Author:
    John Mani, Bill Shannon, Max Spivak
    • Constructor Details

      • ByteArrayDataSource

        public ByteArrayDataSource(InputStream is, String type)
        Create a DataSource from an input stream
        Parameters:
        is - stream
        type - optional MIME type e.g. text/html
      • ByteArrayDataSource

        public ByteArrayDataSource(byte[] data, String type)
        Create a DataSource from a byte array
        Parameters:
        data - data
        type - type e.g. text/html
      • ByteArrayDataSource

        public ByteArrayDataSource(String stringData, String charSetName, String type)
        Create a DataSource from a String
        Parameters:
        stringData - content
        charSetName - optional if null/empty uses UTF-8
        type - optional MIME type e.g. text/html
    • Method Details

      • getInputStream

        public InputStream getInputStream() throws IOException
        Return an InputStream for the data.
        Specified by:
        getInputStream in interface javax.activation.DataSource
        Returns:
        inputstream
        Throws:
        IOException
      • getOutputStream

        public OutputStream getOutputStream() throws IOException
        Throws exception
        Specified by:
        getOutputStream in interface javax.activation.DataSource
        Returns:
        null
        Throws:
        IOException
      • getContentType

        public String getContentType()
        Get Content Type
        Specified by:
        getContentType in interface javax.activation.DataSource
        Returns:
        MIME type e.g. text/html
      • setName

        public ByteArrayDataSource setName(String name)
        Set Name
        Parameters:
        name - name
        Returns:
        this
      • getName

        public String getName()
        Return Name or Class Name and Content Type
        Specified by:
        getName in interface javax.activation.DataSource
        Returns:
        dummy