What is a FileDataSource?

John Zukowski

A FileDataSource is part of the JavaBeans Activation Framework, package javax.activation. It represents a DataSource associated with a file, that relies on a FileTypeMap to associate mime types with file extensions. They can be used to send file attachments:

MimeBodyPart messageBodyPart = 
  new MimeBodyPart();
DataSource source = 
  new FileDataSource(fileAttachment);
messageBodyPart.setDataHandler(
  new DataHandler(source));
messageBodyPart.setFileName(
  filenameString);

The other type of predefined DataSource in the Activation Framework is the URLDataSource.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact