File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Losing newlines in text file when zipping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Losing newlines in text file when zipping" Watch "Losing newlines in text file when zipping" New topic
Author

Losing newlines in text file when zipping

Sean Chang
Greenhorn

Joined: Feb 12, 2009
Posts: 12
Hi,

I am trying to zip up text a file in java, the file includes newline characters, it zips successfully, but when I open it up in winzip, the newline characters are gone, can anyone please advise how to resolve this?

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18114
    
    8

There's nothing in that code which does anything except copy the file byte-for-byte. So what makes you think the newlines are missing in the result?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

Is this code executed on a Linux machine, and is the text file then opened in Notepad? Because Linux uses only \n for line breaks, and Notepad is notorious for only supporting the \r\n combination that Windows uses. Other text editors, including Microsoft's own WordPad (ok, technically not a text editor, but it can handle text files), are a lot better. Notepad++ is often recommended.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36453
    
  15
Rob Spoor wrote: . . . Notepad++ is often recommended.
That is because it is often very good
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Losing newlines in text file when zipping
 
Similar Threads
Problem zipping the file
Zip file produced by Java can't be opened in OS/390 (Mainframe)
Not able to put some files inside Zip file
Unable to create ,zip file
Corrupt file name after compression.