鉴于ZipFilezip
,其ZipEntryentry
和目标FileunzippedEntryFile
,什么是写entry
到unzippedEntryFile
最可读的方式是什么?将ZipEntry写入文件最可读的方法是?
我想出了利用Google Guava和Apache.Commons.IO以下解决方案:
InputSupplier<ByteArrayInputStream> entryInputSupplier = ByteStreams.newInputStreamSupplier(IOUtils.toByteArray(zip.getInputStream(entry)));
Files.copy(entryInputSupplier, unzippedEntryFile);
然而,有些东西告诉我,它可以制成simplier。
感谢,
康拉德
“可读”我也意味着简洁,所以我想避免创建一个新的匿名类,通常我相信可以做更少的调用来完成相同的。 –