ByteStreamDataContentHandler

public class ByteStreamDataContentHandler implements DataContentHandler

ByteStreamDataContentHandler is an implementation of the javax.activation.DataContentHandler that represents a data content handler of a byte stream.

Author:Hugo Y. K. Lam

Constructors

ByteStreamDataContentHandler

public ByteStreamDataContentHandler()

Creates a new instance of ByteStreamDataContentHandler.

Methods

getContent

public Object getContent(DataSource ds)

Returns a byte stream, which is described by the first DataFlavor returned by the getTransferDataFlavors() method, representing the specified data.

Parameters:
  • ds – the data source representing the data to be converted.
Throws:
  • IOException – if unable to convert the data.
Returns:

the byte stream representing the data.

See also: javax.activation.DataContentHandler.getContent(javax.activation.DataSource)

getTransferData

public Object getTransferData(DataFlavor df, DataSource ds)

Returns a byte stream which represents the data to be transferred, ignoring the specified flavor.

Parameters:
  • df – the data flavor representing the requested type.
  • ds – the DataSource representing the data to be converted.
Throws:
  • IOException – if unable to convert the data.
Returns:

the byte stream representing the data.

See also: javax.activation.DataContentHandler.getTransferData(java.awt.datatransfer.DataFlavor,javax.activation.DataSource)

getTransferDataFlavors

public DataFlavor[] getTransferDataFlavors()

Returns an array of DataFlavor objects indicating the flavors the data can be provided in.

Returns:an array of DataFlavor objects.

See also: javax.activation.DataContentHandler.getTransferDataFlavors()

writeTo

public void writeTo(Object obj, String mimeType, OutputStream os)

Converts the object to a byte stream of the specified MIME type and write it to the output stream.

Parameters:
  • obj – the object to be converted.
  • mimeType – the requested MIME type of the resulting byte stream.
  • os – the output stream into which to write the converted byte stream.
Throws:
  • IOException – if unable to convert the given object.

See also: javax.activation.DataContentHandler.writeTo(java.lang.Object,java.lang.String,java.io.OutputStream)