aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Mail + ZipOutputStream + XML file " Watch "Java Mail + ZipOutputStream + XML file " New topic
Author

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,
Nazzy
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19556
    
  16

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
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
nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Mail + ZipOutputStream + XML file
 
Similar Threads
how to zip file clubbing ZipOutputStream in Buffered writer
Different Checksum values retrieved
Generating XML feed for users.
Upload a file to unix and invoke a java method
Working with Java in UNIX