Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

javax.mail.util.SharedByteArrayInputStream error

Posted on 2008-10-06
6
Medium Priority
?
1,358 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
5 Comments
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 22656545
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
ID: 22656556
You need to change the type of the Content and read the data accordingly
0
 

Author Comment

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

Author Comment

by:csharpperson
ID: 22666986
I've solved this myself now ny using getInputStream()

thanks
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 23061466
PAQed with points refunded (30)

Computer101
EE Admin
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

772 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