This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Javamail base64decoderstream instead String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Javamail base64decoderstream instead String" Watch "Javamail base64decoderstream instead String" New topic
Author

Javamail base64decoderstream instead String

Francesco Biegi
Greenhorn

Joined: Oct 29, 2013
Posts: 3
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

Joined: Oct 13, 2005
Posts: 38033
    
  22
Welcome to the Ranch

I shall move this discussion; it is too difficult for “beginning”, and you might get better attention elsewhere.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
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).


Ping & DNS - my free Android networking tools app
Francesco Biegi
Greenhorn

Joined: Oct 29, 2013
Posts: 3
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

Joined: Oct 29, 2013
Posts: 3
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:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javamail base64decoderstream instead String
 
Similar Threads
java run command in Eclipse
Question about Text pad. Hope some one can answer it
process.waitFor() causes program to hang!
a question about executable jar files
Javac.exe not staying open