Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Mail + ZipOutputStream + XML file

 
nazzy khan
Ranch Hand
Posts: 39
Android Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
Nazzy
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could be a line break thing. Unix uses \n (line feed), Windows uses \r\n (carriage return + line feed).
 
nazzy khan
Ranch Hand
Posts: 39
Android Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
nazzy khan
Ranch Hand
Posts: 39
Android Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write-CR-LF-at-end

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.


Thanks,
Nazzy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic