Write out the bytes into the given OutputStream.
(OutputStream os)
| 906 | * Write out the bytes into the given OutputStream. |
| 907 | */ |
| 908 | @Override |
| 909 | public void writeTo(OutputStream os) |
| 910 | throws IOException, MessagingException { |
| 911 | if (bodyLoaded) { |
| 912 | super.writeTo(os); |
| 913 | return; |
| 914 | } |
| 915 | InputStream is = getMimeStream(); |
| 916 | if (this instanceof IMAPNestedMessage) { |
| 917 | String encoding = getEncoding(); |
| 918 | if (encoding != null) |
| 919 | is = MimeUtility.decode(is, encoding); |
| 920 | } |
| 921 | try { |
| 922 | // write out the bytes |
| 923 | byte[] bytes = new byte[16*1024]; |
| 924 | int count; |
| 925 | while ((count = is.read(bytes)) != -1) |
| 926 | os.write(bytes, 0, count); |
| 927 | } finally { |
| 928 | is.close(); |
| 929 | } |
| 930 | } |
| 931 | |
| 932 | /** |
| 933 | * Get the named header. |
no test coverage detected