public InputStream getBodyInputStream() { try { return ((SingleBody) message.getBody()).getInputStream(); } catch (IOException e) { return null; } }
/** * Writes this single body to the given stream. The default implementation copies * the input stream obtained by {@link #getInputStream()} to the specified output * stream. May be overwritten by a subclass to improve performance. * * @param out * the stream to write to. * @throws IOException * in case of an I/O error */ public void writeTo(OutputStream out) throws IOException { if (out == null) throw new IllegalArgumentException(); InputStream in = getInputStream(); SingleBody.copy(in, out); in.close(); }
public SingleBodyBuilder copy(final SingleBody other) throws IOException { if (other == null) { return this; } if (other instanceof TextBody) { String charsetName = ((TextBody) other).getMimeCharset(); if (charsetName != null) { try { this.charset = Charset.forName(charsetName); } catch (IllegalCharsetNameException ex) { throw new UnsupportedEncodingException(charsetName); } catch (UnsupportedCharsetException ex) { throw new UnsupportedEncodingException(charsetName); } } } this.bin = ContentUtil.buffer(other.getInputStream()); return this; }
private Optional<MDNReport> parseReport(Entity report) { LOGGER.debug("Parsing report"); try { return new MDNReportParser().parse(((SingleBody)report.getBody()).getInputStream(), report.getCharset()); } catch (IOException e) { LOGGER.error("unable to parse MESSAGE_DISPOSITION_NOTIFICATION part", e); return Optional.empty(); } }