my dog learned polymorphism
The moose likes Other JSE/JEE APIs and the fly likes Java Mail + ZipOutputStream + XML file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Mail + ZipOutputStream + XML file " Watch "Java Mail + ZipOutputStream + XML file " New topic

Java Mail + ZipOutputStream + XML file

nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39

Hi there,

I have a problem where I have to generate an xml file by java application (having main method) on Unix box (accessing through WinSCP) and then zip it by Java ZipEntry and ZipOutputStream classes and then mail the zip file using Java mail API.

Here are the sequence of operation..

1. Generation of xml file
2. Zipping the xml file into a zip file by java ZipOutputStream class.
3. Mail using the Java mail and activation framework.

So far so good. I got the zip file in my outlook mail box as an attachment.

Next I have compared the xml file which I got from mail (extracted it from attached zip) with the xml file which is on Unix box. I simply moved the xml file to windows using WinSCP.

I have found that there are differences in whole file.. however, every line is exactly same but WinMerge is showing differences in every line.

Has anyone faced this problem? What could be the issue here?

Thanks & Regards,
Rob Spoor

Joined: Oct 27, 2005
Posts: 20279

Could be a line break thing. Unix uses \n (line feed), Windows uses \r\n (carriage return + line feed).

How To Ask Questions How To Answer Questions
nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39

Hi Rob,

Thanks for your reply. I was also thinking the same thing that it could be a carriage return issue.

Do you have any idea how we can resolve this problem?

I will also keep you updated if I can find any kind of patching that can be done here to resolve this issue.

Thanks & Kind Regards,
nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39


May be above url will help. Not sure need to check...

I will let you know whether below code resolves or not?

In C/C++, this is done by creating file streams in "translated" mode. No idea how its done in Java.

I agree. Here's the link:
subject: Java Mail + ZipOutputStream + XML file
It's not a secret anymore!