• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Javamail base64decoderstream instead String

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic