/** * Create a datasource from an input stream. * * @param aIs An InputStream. * @param aType A String. * @throws IOException IOException * @since 1.0 */ public ByteArrayDataSource(final InputStream aIs, final String aType) throws IOException { this.type = aType; this.byteArrayDataSource(aIs); }
/** * Fill email. * * @param email * the email * @throws EmailException * the email exception * @throws IOException * Signals that an I/O exception has occurred. */ public void fillEmail(final MultiPartEmail email) throws EmailException, IOException { email.setHostName(getHost()); email.setSmtpPort(getSmtpPort()); email.addTo(getTo()); email.setFrom(getFrom()); email.setSubject(getSubject()); email.setMsg(getMsg()); email.setSSLOnConnect(isSecured()); if (isRequiresAuthentication()) { email.setAuthentication(getUsername(), getPassword()); } for (int i = 0; i < this.attachements.size(); i++) { final Attachment attachment = this.attachements.get(i); final ByteArrayDataSource ds = new ByteArrayDataSource(attachment.getData(), attachment.getMimeType()); email.attach(ds, attachment.getName(), attachment.getDescription()); } }
/** * Create a datasource from a byte array. * * @param data A byte[]. * @param aType A String. * @throws IOException IOException * @since 1.0 */ public ByteArrayDataSource(final byte[] data, final String aType) throws IOException { this.type = aType; ByteArrayInputStream bis = null; try { bis = new ByteArrayInputStream(data); this.byteArrayDataSource(bis); } finally { if (bis != null) { bis.close(); } } }
/** * Create a datasource from an input stream. * * @param aIs An InputStream. * @param aType A String. * @throws IOException IOException * @since 1.0 */ public ByteArrayDataSource(final InputStream aIs, final String aType) throws IOException { this.type = aType; this.byteArrayDataSource(aIs); }
/** * Create a datasource from a byte array. * * @param data A byte[]. * @param aType A String. * @throws IOException IOException * @since 1.0 */ public ByteArrayDataSource(final byte[] data, final String aType) throws IOException { this.type = aType; ByteArrayInputStream bis = null; try { bis = new ByteArrayInputStream(data); this.byteArrayDataSource(bis); } finally { if (bis != null) { bis.close(); } } }