Solved

javax.mail.util.SharedByteArrayInputStream error

Posted on 2008-10-06
6
1,297 Views
Last Modified: 2013-11-23
hi there
i'm trying to get the body of a mimemessage but i get the error javax.mail.util.SharedByteArrayInputStream and i have no idea why it happening

URL url = new URL(sUrl);
InputStream in = url.openStream();
MimeMessage msg  = new MimeMessage(session, in);

String a = msg.getContent().toString();   - I get javax.mail.util.SharedByteArrayInputStream and I have no idea why

Can anyone see what I'm doign wrong.

i've upgraded from java 1.5 to 1.6 and using the latest mail.jar
0
Comment
Question by:csharpperson
  • 2
  • 2
6 Comments
 
LVL 23

Expert Comment

by:Ajay-Singh
Comment Utility
Getting string from getContent is not a good idea, if you look at javadocs

getContent

public java.lang.Object getContent()
                            throws java.io.IOException,
                                   MessagingException

    Return the content as a Java object. The type of this object is dependent on the content itself. For example, the native format of a "text/plain" content is usually a String object. The native format for a "multipart" message is always a Multipart subclass. For content types that are unknown to the DataHandler system, an input stream is returned as the content.

    This implementation obtains the content from the DataHandler, that is, it invokes getDataHandler().getContent().

    Specified by:
        getContent in interface Part

    Returns:
        Object
    Throws:
        MessagingException -
        java.io.IOException - this is typically thrown by the DataHandler. Refer to the documentation for javax.activation.DataHandler for more details.
    See Also:
        Part, DataHandler.getContent()
0
 
LVL 23

Expert Comment

by:Ajay-Singh
Comment Utility
You need to change the type of the Content and read the data accordingly
0
 

Author Comment

by:csharpperson
Comment Utility
could you give me an example of how i do this please?
0
 

Author Comment

by:csharpperson
Comment Utility
I've solved this myself now ny using getInputStream()

thanks
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
PAQed with points refunded (30)

Computer101
EE Admin
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
changePi Challenge 15 75
countAbc challenge 9 49
mapBully challenge 6 88
thymeleaf natural templating vs JSP 2 23
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now