クラスを使用せずInputStream
に aZipEntry
から aを取得するにはどうすればよいですか?ZipInputStream
ZipFile
33447 次
3 に答える
21
エラー、 はZipInputStream
既に ですInputStream.
別のものは必要ありません。次を取得するとZipEntry
、ストリームがエントリの先頭に配置されます。Javadoc を参照してください。
于 2013-01-30T11:58:51.047 に答える
20
それはこのように動作します
static InputStream getInputStream(File zip, String entry) throws IOException {
ZipInputStream zin = new ZipInputStream(new FileInputStream(zip));
for (ZipEntry e; (e = zin.getNextEntry()) != null;) {
if (e.getName().equals(entry)) {
return zin;
}
}
throw new EOFException("Cannot find " + entry);
}
public static void main(String[] args) throws Exception {
InputStream in = getInputStream(new File("f:/1.zip"), "launch4j/LICENSE.txt");
Scanner sc = new Scanner(in);
while(sc.hasNextLine()) {
System.out.println(sc.nextLine());
}
in.close();
}
于 2013-01-30T12:06:45.393 に答える