/**
  * Removes any content transfer encoding from the stream and returns a Body. This code is
  * taken/condensed from MimeUtility.decodeBody
  */
 private Body decodeBody(
     InputStream in, String contentTransferEncoding, int size, MessageRetrievalListener listener)
     throws IOException {
   // Get a properly wrapped input stream
   in = MimeUtility.getInputStreamForContentTransferEncoding(in, contentTransferEncoding);
   BinaryTempFileBody tempBody = new BinaryTempFileBody();
   OutputStream out = tempBody.getOutputStream();
   try {
     byte[] buffer = new byte[COPY_BUFFER_SIZE];
     int n = 0;
     int count = 0;
     while (-1 != (n = in.read(buffer))) {
       out.write(buffer, 0, n);
       count += n;
       /*                if (listener != null) {
           listener.loadAttachmentProgress(count * 100 / size);
       }*/
     }
   } catch (Base64DataException bde) {
     String warning = "\n\n" + Email.getMessageDecodeErrorString();
     out.write(warning.getBytes());
   } finally {
     out.close();
   }
   return tempBody;
 }