Output the message as an RFC 822 format stream, without specified headers. If the property "mail.pop3.cachewriteto" is set to "true", and ignoreList is null, and the message hasn't already been cached as a side effect of other operations, the message content is cached before being written. Otherwi
(OutputStream os, String[] ignoreList)
| 557 | * @see javax.activation.DataHandler#writeTo |
| 558 | */ |
| 559 | @Override |
| 560 | public synchronized void writeTo(OutputStream os, String[] ignoreList) |
| 561 | throws IOException, MessagingException { |
| 562 | InputStream rawcontent = rawData.get(); |
| 563 | if (rawcontent == null && ignoreList == null && |
| 564 | !((POP3Store)(folder.getStore())).cacheWriteTo) { |
| 565 | if (folder.logger.isLoggable(Level.FINE)) |
| 566 | folder.logger.fine("streaming msg " + msgnum); |
| 567 | if (!folder.getProtocol().retr(msgnum, os)) { |
| 568 | expunged = true; |
| 569 | throw new MessageRemovedException("can't retrieve message #" + |
| 570 | msgnum + " in POP3Message.writeTo"); // XXX - what else? |
| 571 | } |
| 572 | } else if (rawcontent != null && ignoreList == null) { |
| 573 | // can just copy the cached data |
| 574 | InputStream in = ((SharedInputStream)rawcontent).newStream(0, -1); |
| 575 | try { |
| 576 | byte[] buf = new byte[16*1024]; |
| 577 | int len; |
| 578 | while ((len = in.read(buf)) > 0) |
| 579 | os.write(buf, 0, len); |
| 580 | } finally { |
| 581 | try { |
| 582 | if (in != null) |
| 583 | in.close(); |
| 584 | } catch (IOException ex) { } |
| 585 | } |
| 586 | } else |
| 587 | super.writeTo(os, ignoreList); |
| 588 | } |
| 589 | |
| 590 | /** |
| 591 | * Load the headers for this message into the InternetHeaders object. |