は、ZIPファイルを開くことが可能で、そのままフォルダとして機能します。私は一度にhundersからZIPファイル内の1つのフォルダの部分解凍を行う必要があります。標準の反復処理は遅いです(ID = 432のフォルダを開く必要があると仮定すると、前に431個のフォルダがチェックされます)。一部のデータをzipから部分的に解凍する方法はありますか?Android - ZIPをフォルダとして開く
おかげ
は、ZIPファイルを開くことが可能で、そのままフォルダとして機能します。私は一度にhundersからZIPファイル内の1つのフォルダの部分解凍を行う必要があります。標準の反復処理は遅いです(ID = 432のフォルダを開く必要があると仮定すると、前に431個のフォルダがチェックされます)。一部のデータをzipから部分的に解凍する方法はありますか?Android - ZIPをフォルダとして開く
おかげ
この例を参考にしてください。
public void unzip() {
try {
FileInputStream fin = new FileInputStream(_zipFile);
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
Log.v("Decompress", "Unzipping " + ze.getName());
System.out.println("^^^^^^UnzippingFile^"+ze.getName());
///code to search is given string exists or not in a Sentence
String haystack = ze.getName();
String needle1 = ".DS_Store";
int index1 = haystack.indexOf(needle1);
if (index1 != -1)
{
System.out.println("The string contains the substring "
+ needle1);
continue;
}
/*else
System.out.println("The string does not contain the
substring " + needle1);*/
if(ze.isDirectory()) {
_dirChecker(ze.getName());
} else {
FileOutputStream fout = new FileOutputStream(_location +
ze.getName());
// replace for loop with:
byte[] buffer = new byte[1024];
int length;
while ((length = zin.read(buffer))>0) {
fout.write(buffer, 0, length);
}
zin.closeEntry();
fout.close();
}
}////Outer While
zin.close();
} catch(Exception e) {
Log.e("Decompress", "unzip", e);
}
}
private void _dirChecker(String dir) {
File f = new File(_location + dir);
if(!f.isDirectory()) {
f.mkdirs();
}
}
はZipFile
here上getEntry
方法を見てみましょう。