/** * Get an InputStream which holds all headers of the given MimeMessage * * @param message the MimeMessage used as source * @param ignoreList the String[] which holds headers which should be ignored * @return stream the InputStream which holds the headers * @throws MessagingException */ @SuppressWarnings("unchecked") public static InputStream getHeadersInputStream(MimeMessage message, String[] ignoreList) throws MessagingException { return new InternetHeadersInputStream(message.getNonMatchingHeaderLines(ignoreList)); }
/** * Write the message headers to the given outputstream * * @param headers the Enumeration which holds the headers * @param headerOs the OutputStream to which the headers get written * @throws MessagingException */ @SuppressWarnings("unchecked") public static void writeHeadersTo(Enumeration headers, OutputStream headerOs) throws MessagingException { try { IOUtils.copy(new InternetHeadersInputStream(headers), headerOs); } catch (IOException e) { throw new MessagingException("Unable to write headers to stream", e); } }
public synchronized void writeTo(OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws IOException, MessagingException { if (source != null && !isModified()) { //We do not want to instantiate the message... just read from source // and write to this outputstream //First handle the headers InputStream in = source.getInputStream(); try { InternetHeaders headers = new InternetHeaders(in); IOUtils.copy(new InternetHeadersInputStream(headers), headerOs); IOUtils.copy(in, bodyOs); } finally { IOUtils.closeQuietly(in); } } else { MimeMessageUtil.writeToInternal(this, headerOs, bodyOs, ignoreList); } }
} else { try { in = new CombinedInputStream(new InputStream[] { new InternetHeadersInputStream(message.getAllHeaderLines()), message.getRawInputStream() }); } catch (MessagingException e) {