Hi I am getting the following exception
Exception in thread "main" java.lang.ClassCastException: javax.mail.util.SharedByteArrayInputStream cannot be cast to javax.mail.Multipart
I am not getting any compilation exception in Eclipse IDE, but when I am trying build the project I am getting this exception.
After building the project, I am running the project through java -jar, so its not satisfying the if(content instanceof Multipart) condition, but when i am running from the Eclipse IDE its working fine. Any pointers will greatly helpful to me
From the eclipse IDE I'm getting the megssage.getContent() as javax.mail.internet.MimeMultipart@1dc0e7a but when running using the jar file I'm getting the content as javax.mail.util.SharedByteArrayInputStream@2f0d54
Please can you tell me what is the difference between them.
Modified code is:
InputStream inStream = null;
if(!message.getContentType().contains("text/plain")){
Object content = message.getContent();
if (message.isMimeType("multipart/*")) {
//message.isMimeType("multipart/*")||
Multipart multipart = (Multipart) content;
for (int j = 0; j < multipart.getCount(); j++) {
BodyPart bodyPart = multipart.getBodyPart(j);
inStream = bodyPart.getInputStream();
fileName=bodyPart.getFileName();
}
}
else{
System.out.println("content not instance of multipart");
}`enter code here`
Please can anyone help me out in solving this issue..
Thanks in advance...