4

ZipFileクラスを使用して、複数のファイルのアーカイブからその名前を使用してファイルを解凍したいと思います。コンストラクターに渡す zip ファイル名とディレクトリの文字列を取得するにはどうすればよいZipFileですか?

4

1 に答える 1

4

AssetManager と ZipInputStream http://developer.android.com/reference/android/content/res/AssetManager.htmlを使用できます。

ZipInputStream in = null;
try {
    final String zipPath = "data/sample.zip";
    // Context.getAssets()
    in = new ZipInputStream(getAssets().open(zipPath));
    for (ZipEntry entry = in.getNextEntry(); entry != null; entry = in.getNextEntry()) {
        // handle the zip entry
    }
} catch (IOException e) {
    Log.e(TAG, e.getMessage());
} finally {
    try {
        if (in != null) {
            in.close();
        }
    } catch (IOException ignored) {
    }
    in = null;
}
于 2010-06-16T12:04:52.483 に答える