public InputStream getInputStream() throws IOException { try { InputStream stream; if (part instanceof MimeMessage) { stream = ((MimeMessage) part).getContentStream(); } else if (part instanceof MimeBodyPart) { stream = ((MimeBodyPart) part).getContentStream(); } else { throw new MessagingException("Unknown part"); } return checkPartEncoding(part, stream); } catch (MessagingException e) { throw (IOException) new IOException(e.getMessage()).initCause(e); } }