P
P
programmerjava2015-07-15 18:16:25
Java
programmerjava, 2015-07-15 18:16:25

JavaMail readable email encoding?

Hello!!!
Please, please help!!
I am writing a program to read data from mail.
The program receives each letter and compares the header.
I always take it like this,
String subject = message.getSubject();
but the trouble is that when I try to output, at least for verification,
out.println(subject)
torus letters are displayed in the console with a question ???
for example: 'Order on mysite.ru' displays as '????? ?? mysite.ru'
and Yandex writes the title correctly

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
programmerjava, 2015-07-15
@programmerjava

Decided!!!
Did it differently.

ByteArrayOutputStream output = new ByteArrayOutputStream();
message.writeTo(output);
String raw = output.toString();
int subjectIdx = raw.indexOf("Subject:");
int offIdx = raw.indexOf("\n",subjectIdx);
String sub = raw.substring(subjectIdx + 9, offIdx);

S
script88, 2015-07-15
@script88

Check encoding in console

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question