L
laredotornado
Hi,
I'm using Java 1.5 no Mac 10.5.6. I found this code online that
should zip a file. Although it zips the file, when I manually unzip
it at the command line, there are all these extra characters (they
appear as "^@^@^@^@^@" in vi). Thus, the unzipped version of the file
is a different size than the original file. Does anyone know how to
eliminate these extra characters?
Thanks, - Dave
========================The code=============================
byte[] buf = new byte[1024];
FileInputStream fis = new FileInputStream(filename);
fis.read(buf,0,buf.length);
CRC32 crc = new CRC32();
ZipOutputStream s = new ZipOutputStream(
(OutputStream)new FileOutputStream(zipfilename));
s.setLevel(6);
ZipEntry entry = new ZipEntry(filename);
entry.setSize((long)buf.length);
crc.reset();
crc.update(buf);
entry.setCrc( crc.getValue());
s.putNextEntry(entry);
s.write(buf, 0, buf.length);
s.finish();
s.close();
I'm using Java 1.5 no Mac 10.5.6. I found this code online that
should zip a file. Although it zips the file, when I manually unzip
it at the command line, there are all these extra characters (they
appear as "^@^@^@^@^@" in vi). Thus, the unzipped version of the file
is a different size than the original file. Does anyone know how to
eliminate these extra characters?
Thanks, - Dave
========================The code=============================
byte[] buf = new byte[1024];
FileInputStream fis = new FileInputStream(filename);
fis.read(buf,0,buf.length);
CRC32 crc = new CRC32();
ZipOutputStream s = new ZipOutputStream(
(OutputStream)new FileOutputStream(zipfilename));
s.setLevel(6);
ZipEntry entry = new ZipEntry(filename);
entry.setSize((long)buf.length);
crc.reset();
crc.update(buf);
entry.setCrc( crc.getValue());
s.putNextEntry(entry);
s.write(buf, 0, buf.length);
s.finish();
s.close();