/**
* description: java读取两次压缩的文件的内容(zip文件里还是zip文件)
* author: Administrator
* create: 2020/4/13 0013
**/
public class TestClass {
public static void main(String[] args) throws Exception {
//获取文件输入流
FileInputStream input = new FileInputStream("C:\\Users\\Administrator\\Desktop\\NGRM_PDF_20200305195800.ZIP");
ZipInputStream zipInputStream = new ZipInputStream(new BufferedInputStream(input), Charset.forName("GBK")/*可以设置编码*/);
ZipEntry ze;
//循环遍历
while ((ze = zipInputStream.getNextEntry()) != null) {
if (ze.getName() != null && ze.getName().endsWith(".ZIP")) {
ZipEntry ze2;
ZipInputStream zipInputStream1 = new ZipInputStream(zipInputStream);
while ((ze2 = zipInputStream1.getNextEntry()) != null) {
System.out.println("文件名:" + ze2.getName() + " 文件大小:" + ze2.getSize() + " bytes");
System.out.println("文件内容:");
//读取
BufferedReader br = new BufferedReader(new InputStreamReader(zipInputStream1, Charset.forName("GBK")));
String line;
//内容不为空,输出
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}
//一定记得关闭流
zipInputStream1.closeEntry();
zipInputStream1.close();
}
}
input.close();
zipInputStream.close();
}
}
java读取两次zip压缩的文件的内容
最新推荐文章于 2024-04-10 14:21:32 发布
579

被折叠的 条评论
为什么被折叠?



