1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
public void readZipFiles(String filename) {
try {
byte[] buf = new byte[1024];
ZipInputStream zipinputstream = null;
ZipEntry zipentry;
zipinputstream = new ZipInputStream(new FileInputStream(filename));
zipentry = zipinputstream.getNextEntry();
while (zipentry != null) {
// for each entry to be extracted
String entryName = zipentry.getName();
System.out.println("File ::" + entryName);
RandomAccessFile rf;
File newFile = new File(entryName);
String directory = newFile.getParent();
if (directory == null) {
if (newFile.isDirectory())
break;
}
rf = new RandomAccessFile(entryName, "r");
String line;
if ((line = rf.readLine()) != null) {
System.out.println(line);
}
rf.close();
zipinputstream.closeEntry();
zipentry = zipinputstream.getNextEntry();
}// while
zipinputstream.close();
} catch (Exception e) {
e.printStackTrace();
}
} |
Partager