Why do I get the UnsupportedEncodingException when I invoke getContent() on a bodypart that contains text data?
Textual bodyparts (i.e., bodyparts whose type is “text/plain”, “text/html”, or “text/xml”) return Unicode String objects when getContent() is used. Typically, such bodyparts internally hold their textual data in some non Unicode charset. JavaMail (through the corresponding DataContentHandler) attempts to convert that data into a Unicode string. The underlying JDK’s charset converters are used to do this. If the JDK does not support a particular charset, then the UnsupportedEncodingException is thrown. In this case, you can use the getInputStream() method to retrieve the content as a stream of bytes.
Related Questions
- If the communication between the cabinet and the SIM occurs via HTTP, how is the data protected since it is transmitted in plain text?
- Why do I get the UnsupportedEncodingException when I invoke getContent() on a bodypart that contains text data?
- What is the best way to transfer my data (from Excel, from SPSS, from a text file, etc.) into Stata?