javax.mail.util.SharedByteArrayInputStream error

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
csharppersonAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Computer101Connect With a Mentor Commented:
PAQed with points refunded (30)

Computer101
EE Admin
0
 
Ajay-SinghCommented:
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
 
Ajay-SinghCommented:
You need to change the type of the Content and read the data accordingly
0
 
csharppersonAuthor Commented:
could you give me an example of how i do this please?
0
 
csharppersonAuthor Commented:
I've solved this myself now ny using getInputStream()

thanks
0
All Courses

From novice to tech pro — start learning today.