Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javamail base64decoderstream instead String

 
Francesco Biegi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

i've a program to precess email and put them on DB. Since my provider has changed the login security (now its SSL connection), i've modified the connection config.

Now the problem its really strange: if i run my program from Eclipse (Run -> Run), all works fine.

First i get the content: Object content = message.getContent(); and on next i verify it
example: if (content instanceof String) {}

In this case, all works well.

If from Eclipse i create a runnable JAR (i need it to launch my program from batch file (.bat) ) and then i launch it, when i retrieve the content, i dont get an String from getContent(). but i get an BASE64DecoderStream.

I've tried to launch the program from the same machine, and from Eclipse i get String, and from a DOS .bat file, i get an BASE64DecoderStream.

Could you help me to understand this ?
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I shall move this discussion; it is too difficult for “beginning”, and you might get better attention elsewhere.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The explanation is in the javadocs of Part and Part.getContent(): the type depends on the setup of the DataHandler mechanism, and that can differ between machines and between JVMs. Apparently Eclipse sets it up differently than a standalone JVM (no surprise there, really, as IDE environment frequently differ from non-IDE environments).
 
Francesco Biegi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Campbell :-)

So, i'll try to understand how setup the DataHandler and i will test again.

If i will find some solution, i'll post there.
 
Francesco Biegi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

i havent find a real solution about this problem. I have simply do this:

1) If statement to check if the content ( Object content = message.getContent(); ) is instanceof InputStream
2) Read the stream and place it on String (or String buffer maybe is better for performance)
3) Getting byte from String created and create new one with format UTF-8:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic