ZipEntry peculiarity

R

Roedy Green

The docs on ZipEntry say nothing about the element name. They imply
by their silence that whatever you put in there should come out the
other end unmolested.

Winzip uses / as the directory separator char, but I have discovered
ZipEntry is using \ even when I specify / in my element names.

You can see this my viewing the generated file with a hex viewer.
 
H

Harald Hein

Roedy Green said:
The docs on ZipEntry say nothing about the element name.

They implicitely do by refering to the zip "standard". That one clearly
states the meaning of "/".
Winzip uses / as the directory separator char, but I have discovered
ZipEntry is using \ even when I specify / in my element names.

I think you mixed up "\" and "/" in that sentence. Even on windows, the
path separator in a ZipEntry is "/". In fact, a lot of windows ZIP
tools still get this wrong and use "\" in zip files they generate.

But a lot of Java tools get it wrong when packing or unpacking a zip
file, too. You must replace the platform specific file path separtor
with a "/" when writing to a zip file and providing the entry name, and
you must replace every "/" in a zip file entry name when you read a zip
file entry and want to store it as a normal file, using the zip file
entry name as file name.
 
R

Roedy Green

I think you mixed up "\" and "/" in that sentence. Even on windows, the
path separator in a ZipEntry is "/". In fact, a lot of windows ZIP
tools still get this wrong and use "\" in zip files they generate.

Nope. I meant what I said. Whether I use / or \ in my entry name,
when I look at the generated zip file with hex viewer, the darn things
have been converted to \. This is a bug. They should be converted to
/.


I will have to double check that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,477
Members
44,898
Latest member
BlairH7607

Latest Threads

Top