是否有可能從壓縮文件中獲取InputStream文件?我只知道這一個:How to extract a single file from a remote archive file?這給我只是文件的字節。獲取壓縮文件的輸入流?
所以有什麼功能有這樣的方法:InputStream getFile(String path, File zipFile)
其中path
是ziped文件中的路徑?
是否有可能從壓縮文件中獲取InputStream文件?我只知道這一個:How to extract a single file from a remote archive file?這給我只是文件的字節。獲取壓縮文件的輸入流?
所以有什麼功能有這樣的方法:InputStream getFile(String path, File zipFile)
其中path
是ziped文件中的路徑?
試試這個:
ZipFile zf = new ZipFile(file);
try {
InputStream in = zf.getInputStream(zf.getEntry("file.txt"));
// ... read from 'in' as normal
} finally {
zf.close();
}
欲瞭解更多信息請參閱this tutorial。
您可以使用ByteArrayInputStream,它將構造函數中的字節數組作爲輸入。