A
Aerodyne
Hi all,
If I'm using an unzip method like this ... how do I get it to unzip a
file (about 6MB) uploaded to a location... there should only be one zip
file in this temp folder, once it's been unziped then uploaded to the
server everything in that folder will be deleted.
public void unpackZip() {
try {
final int BUFFER = 2048;
BufferedOutputStream dest = null;
FileInputStream fis = new FileInputStream(???); // is this
right
CheckedInputStream checksum = new CheckedInputStream(fis, new
Adler32()); // faster checksum than CRC32
ZipInputStream zis = new ZipInputStream(new
BufferedInputStream(checksum));
ZipEntry entry;
while((entry = zis.getNextEntry()) != null) {
// System.out.println("Extracting: " +entry);
int count;
byte data[] = new byte[BUFFER];
// write the files to the disk
FileOutputStream fos = new
FileOutputStream(entry.getName());
dest = new BufferedOutputStream(fos, BUFFER);
while ((count = zis.read(data, 0, BUFFER)) != -1) {
dest.write(data, 0, count);
}
dest.flush();
dest.close();
}
zis.close();
// System.out.println("Checksum:
"+checksum.getChecksum().getValue());
} catch(Exception e) {
e.printStackTrace();
}
}
I need help w/ the following please:
- unzip a file
- shows the checksum error if possible... jsp is the page + tomcat 5.
- delete folders contants... after upload
If I'm using an unzip method like this ... how do I get it to unzip a
file (about 6MB) uploaded to a location... there should only be one zip
file in this temp folder, once it's been unziped then uploaded to the
server everything in that folder will be deleted.
public void unpackZip() {
try {
final int BUFFER = 2048;
BufferedOutputStream dest = null;
FileInputStream fis = new FileInputStream(???); // is this
right
CheckedInputStream checksum = new CheckedInputStream(fis, new
Adler32()); // faster checksum than CRC32
ZipInputStream zis = new ZipInputStream(new
BufferedInputStream(checksum));
ZipEntry entry;
while((entry = zis.getNextEntry()) != null) {
// System.out.println("Extracting: " +entry);
int count;
byte data[] = new byte[BUFFER];
// write the files to the disk
FileOutputStream fos = new
FileOutputStream(entry.getName());
dest = new BufferedOutputStream(fos, BUFFER);
while ((count = zis.read(data, 0, BUFFER)) != -1) {
dest.write(data, 0, count);
}
dest.flush();
dest.close();
}
zis.close();
// System.out.println("Checksum:
"+checksum.getChecksum().getValue());
} catch(Exception e) {
e.printStackTrace();
}
}
I need help w/ the following please:
- unzip a file
- shows the checksum error if possible... jsp is the page + tomcat 5.
- delete folders contants... after upload