我正在尝试使用 ZipInputStream 修改 web.xml。要读取的文件是 web.xml,它位于 ear/war 文件中
C:/XX.ear/YY.war/WEB-INF/web.xml
ZipFile zipFile = new ZipFile("C:/XX.ear");
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while(entries.hasMoreElements()){
ZipEntry entry = entries.nextElement();
if(entry.getName().equalsIgnoreCase("YY.war")){
ZipInputStream inputStream = new ZipInputStream(zipFile.getInputStream(entry));
ZipEntry zipEntry;
while(( zipEntry = inputStream.getNextEntry())!=null)
{
System.out.println(zipEntry.getName());// Prints WEB-INF/web.xml
if (zipEntry.getName().endsWith(".xml")) {
ZipInputStream iStream = new ZipInputStream(zipFile.getInputStream(zipEntry));
// throws NullPointerException here
}
}
}
}
new ZipInputStream( zipFile .getInputStream(zipEntry)) 我无法指向内部 zip 文件来获取内部战争文件的输入流
是否可以将内部 zipentry 读取为输入流?