raw フォルダーに保存されている zip ファイルを解凍しようとしています。コードは次のとおりです
try
{
File myDir = new File(getFilesDir().getAbsolutePath());
File newFile = new File(myDir + "/imageFolder");
if(!newFile.exists())
{
newFile.mkdir();
}
ZipInputStream zipIs = new ZipInputStream(con
.getResources().openRawResource(R.raw.images));
ZipEntry ze = null;
while ((ze = zipIs.getNextEntry()) != null)
{
Log.v("Name", ze.getName());
Log.v("Size", "" + ze.getSize());
if(ze.getSize() >0)
{
FileOutputStream fout = new FileOutputStream(newFile
+ "/" + ze.getName());
byte[] buffer = new byte[1024];
int length = 0;
while ((length = zipIs.read(buffer)) > 0)
{
fout.write(buffer, 0, length);
}
zipIs.closeEntry();
fout.close();
}
}
zipIs.close();
} catch (Exception e)
{
e.printStackTrace();
}
しかし、私はこのエラーが発生し続けます
01-18 11:24:28.301: W/System.err(2285): java.io.FileNotFoundException: /data/data/com.example.ziptests/files/imageFolder/TestImages/background.png (ディレクトリではない)
なぜこれが原因なのかまったくわかりません。ファイルが見つかりますが、それらを書き出すと、そのエラーが発生します。元々、Mac で zip ファイルを圧縮したことが原因である問題を見つけたので、代わりに Windows マシンでファイルを圧縮して、1 つの問題を取り除きました (Mac で圧縮すると、これらの余分なフォルダーが追加されます)。および解凍しようとしたときにエラーを引き起こす store.ds などのファイル)、しかし、これはディレクトリエラーではありません。
なぜこれが起こっているのですか?