List of usage examples for javax.activation FileDataSource getContentType
public String getContentType()
From source file:stg.pr.engine.mailer.SmallEmailAttachment.java
/** * Constructs an email attachment with the given name and the file. * @param name of the file that will get associated with the email. * @param file to be attached./*from ww w.j av a2s.com*/ * @throws IOException */ public SmallEmailAttachment(String name, File file) throws IOException { super(name, file); //this will throw exception in case the file does not exist if (file.length() > EMailAttachment.SMALL_SIZE.longValue()) { throw new IllegalArgumentException("Small email attachments are for file size < " + EMailAttachment.SMALL_SIZE.longValue() + " bytes."); } FileDataSource fds = new FileDataSource(file); contentType = fds.getContentType(); bytes = FileUtils.readFileToByteArray(file); }