3 import java.io.FileInputStream;
4 import java.io.FileOutputStream;
5 import java.io.IOException;
6 import java.util.zip.ZipEntry;
7 import java.util.zip.ZipInputStream;
13 * @param aZipFile zipファイル
14 * @param aOutDir 出力先ディレクトリ
15 * @throws java.io.IOException
17 public static void decode(File aZipFile, String aOutDir) throws IOException {
18 FileInputStream fileIn = null;
19 FileOutputStream fileOut = null;
20 ZipInputStream zipIn = null;
23 File outDir = new File(aOutDir);
26 fileIn = new FileInputStream(aZipFile);
27 zipIn = new ZipInputStream(fileIn);
29 ZipEntry entry = null;
30 while ((entry = zipIn.getNextEntry()) != null) {
31 if (entry.isDirectory()) {
32 String relativePath = entry.getName();
33 outDir = new File(outDir, relativePath);
37 String relativePath = entry.getName();
38 File outFile = new File( outDir, relativePath );
40 File parentFile = outFile.getParentFile();
43 fileOut = new FileOutputStream( outFile );
45 byte[] buf = new byte[ 256 ];
47 while ((size = zipIn.read(buf)) > 0){
48 fileOut.write(buf, 0, size);
56 catch (IOException e) {
64 catch (IOException e) {}
66 if (fileOut != null) {
70 catch(IOException e) {}