简体   繁体   English

Matlab,如何在不解压缩的情况下读取zip.file中的文件

[英]Matlab , How to read files in a zip.file without unzipping

My manager let me do this. 我的经理让我这样做。

I searched online and I don't think Matlab has a direct way way to do this. 我在网上搜索过,但我认为Matlab没有直接的方法可以做到这一点。 (if there is, please tell me.) (如果有,请告诉我。)

In my opinion, we can implement it in Java API, and then let matlab use java codes. 我认为,我们可以在Java API中实现它,然后让Matlab使用Java代码。 Can someone tell me if this way is ok? 有人可以告诉我这种方式是否可以吗? Otherwise do you guys have some other methods? 否则你们还有其他方法吗?

With many thanks. 非常感谢。

If you want to list the zip file contents without unzipping, the following code does just that: 如果要列出压缩文件的内容而不进行解压缩,则下面的代码可以做到这一点:

function filelist = listzipcontents(zipFilename)
% Create a Java file of the ZIP filename.
zipJavaFile  = java.io.File(zipFilename);
% Create a Java ZipFile and validate it.
zipFile = org.apache.tools.zip.ZipFile(zipJavaFile);
% Extract the entries from the ZipFile.
entries = zipFile.getEntries;
% Initialize the file list.
filelist={};
% Loop through the entries and add to the file list.
while entries.hasMoreElements
    filelist = cat(1,filelist,char(entries.nextElement));
end
end

Quoted by: 引用者:

http://www.mathworks.com/matlabcentral/answers/10945-read-files-in-zip-file-without-unzipping http://www.mathworks.com/matlabcentral/answers/10945-read-files-in-zip-file-without-unzipping

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM