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

时间:2014-10-13 15:36:14

标签: java matlab zip

我的经理让我这样做。

我在线搜索,我不认为Matlab有直接的方式来做到这一点。 (如果有,请告诉我。)

在我看来,我们可以在Java API中实现它,然后让matlab使用java代码。有人能告诉我这种方式是否合适?不然你们有其他方法吗?

非常感谢。

1 个答案:

答案 0 :(得分:1)

如果要在不解压缩的情况下列出zip文件内容,以下代码就是这样:

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

引用者:

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