jwandscheer
jwandscheer

Reputation: 178

JAVAMAIL get Content with InputStream

I'm trying to get the content Text of a Message in my Android App with an InputStream, because there I can get a line Separator. I'm getting the following Exception when I'm trying it:

java.lang.ClassCastException: java.lang.String cannot be cast to java.io.InputStream

This is my Code:

Object o = message.getContent();

InputStream is = (InputStream)o;
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
  sb.append(line);
}
String everything = sb.toString();

Do you know what the problem is? In every Javamail - Thread you can read that this Method runs.

Upvotes: 0

Views: 571

Answers (1)

Bill Shannon
Bill Shannon

Reputation: 29971

Use the Message.getInputStream method.

Upvotes: 2

Related Questions