简体   繁体   中英

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. (if there is, please tell me.)

In my opinion, we can implement it in Java API, and then let matlab use java codes. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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