Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check that file exists inside a zip archive?

How to check that file exists inside a zip archive?
For example, check whether app.apk contains classes.dex.
I want to find a solution that uses Java NIO.2 Path and without extracting the whole archive if possible.

I've tried and it didn't work:

Path classesFile = Paths.get("app.apk", "classes.dex");  // apk file with classes.dex
if (Files.exists(apkFile))  // false!
    ...
like image 712
naXa Avatar asked Sep 07 '15 10:09

naXa


1 Answers

My solution is:

Path apkFile = Paths.get("app.apk");
FileSystem fs = FileSystems.newFileSystem(apkFile, null);
Path dexFile = fs.getPath("classes.dex");
if (Files.exists(dexFile))
    ...
like image 62
naXa Avatar answered Oct 28 '22 17:10

naXa