我有一个数据库,包含了BLOB和一个密码保护的ZIP文件。通常情况下,我会使用标准的File对象来处理。
File zipFile = new File("C:\\file.zip");
net.lingala.zip4j.core.ZipFile table = new net.lingala.zip4j.core.ZipFile(zipFile);
if (table.isEncrypted())
table.setPassword(password);
net.lingala.zip4j.model.FileHeader entry = table.getFileHeader("file_inside_the_zip.txt");
return table.getInputStream(entry); //Decrypted inputsteam!
我的问题是,如何在不使用临时文件的情况下实现这样的功能,并纯粹地获取blob的输入流。到目前为止,我有类似于以下内容:
InputStream zipStream = getFileFromDataBase("stuff.zip");
//This point forward I have to save zipStream as a temporary file and use the traditional code above
net.lingala.zip4j.core.ZipFile#readZipInfo
为例,它纯粹基于文件而非流来实现。但由于Zip4J是开源的,可以进行扩展……但可能需要一些工作。 - Alex