Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
package routines;
import java.io.*;
import java.util.zip.*;
public class forum7756 {
static final int size = 4096;
public static void extractingFileFromZip(String outputFolder) {
String path = outputFolder;
try {
BufferedOutputStream dest = null;
FileInputStream fis = new FileInputStream("D:/ttt.zip");
ZipInputStream zis = new ZipInputStream(
new BufferedInputStream(fis));
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
System.out.println("Extracting: " + entry);
int count;
byte buffer[] = new byte;
// write the files to the disk
String filePath = path + entry.getName();
File outFile = new File(filePath);
if (!outFile.exists()) {
outFile.getParentFile().mkdirs();
}
FileOutputStream fos = new FileOutputStream(outFile);
dest = new BufferedOutputStream(fos);
while ((count = zis.read(buffer)) != -1) {
dest.write(buffer);
}
dest.flush();
dest.close();
}
zis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
package routines;
import java.io.*;
import java.util.zip.*;
public class forum7756 {
static final int size = 4096;
public static void extractingFileFromZip(String outputFolder) {
String path = outputFolder;
try {
BufferedOutputStream dest = null;
FileInputStream fis = new FileInputStream("D:/ttt.zip");
ZipInputStream zis = new ZipInputStream(
new BufferedInputStream(fis));
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
System.out.println("Extracting: " + entry);
int count;
byte buffer[] = new byte;
// write the files to the disk
String filePath = path + entry.getName();
File outFile = new File(filePath);
if (!outFile.exists()) {
outFile.getParentFile().mkdirs();
}
FileOutputStream fos = new FileOutputStream(outFile);
dest = new BufferedOutputStream(fos);
while ((count = zis.read(buffer)) != -1) {
dest.write(buffer);
}
dest.flush();
dest.close();
}
zis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Isn't there a way to just get the content of the ZipEntry from the loop?