Java读取zip文件内容
public static void main(String[] args)throws Exception{ String filePath = "D:\\test\\test.zip"; InputStream inputStream = new BufferedInputStream(new FileInputStream(filePath)); ZipInputStream zipInputStream = new ZipInputStream(inputStream); ZipEntry zipEntry; while ((zipEntry = zipInputStream.getNextEntry()) != null) { if (zipEntry.isDirectory()) { } else { ByteArrayOutputStream baos = new ByteArrayOutputStream(); while (true) { int bytes = zipInputStream.read(); if (bytes == -1) { break; } baos.write(bytes); } baos.close(); System.out.println(String.format("Name:%s,Content:%s",zipEntry.getName(),new String(baos.toByteArray()))); } } zipInputStream.closeEntry(); zipInputStream.close(); }