• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

Losing newlines in text file when zipping

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

 
Marshal
Posts: 27895
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 22753
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 78408
374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote: . . . Notepad++ is often recommended.

That is because it is often very good
 
reply
    Bookmark Topic Watch Topic
  • New Topic