Question

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.

Was it helpful?

Solution

Use the Message.getInputStream method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top