Androidファイル解凍ツール類


これはAndroidファイル解凍ツールクラスです.サブディレクトリを含むファイル解凍方法が必要な場合は、アドレス:Androidサブディレクトリ解凍方法
/**
	 *           
	 * 
	 * @param zipFile
	 *                   
	 * @param targetDir
	 *                    
	 */
	public static void singleZip(String zipFile, String targetDir) {
		int BUFFER = 4096; //          4KB,
		String strEntry; //     zip     
		try {
			BufferedOutputStream dest = null; //      
			FileInputStream fis = new FileInputStream(zipFile);
			ZipInputStream zis = new ZipInputStream(
					new BufferedInputStream(fis));
			ZipEntry entry; //   zip     
			while ((entry = zis.getNextEntry()) != null) {
				try {

					LogUtils.i(TAG, "entry=" + entry);
					int count;
					byte data[] = new byte[BUFFER];
					strEntry = entry.getName();
					LogUtils.i(TAG, "strEntry=" + strEntry);
					File entryFile = new File(targetDir + strEntry);
					LogUtils.i(TAG, "entryFile=" + targetDir + strEntry);
					File entryDir = new File(entryFile.getParent());
					LogUtils.i(TAG, "entryDir=" + entryFile.getParent());
					if (!entryDir.exists()) {
						entryDir.mkdirs();
					}
					FileOutputStream fos = new FileOutputStream(entryFile);
					dest = new BufferedOutputStream(fos, BUFFER);
					while ((count = zis.read(data, 0, BUFFER)) != -1) {
						dest.write(data, 0, count);
					}
					dest.flush();
					dest.close();
				} catch (Exception ex) {
					ex.printStackTrace();
					LogUtils.d(TAG, ex.getMessage());
				}
			}
			zis.close();
		} catch (Exception cwj) {
			LogUtils.e(TAG, cwj.getMessage());
		}
	}
   
                     
これがAndroid単一ディレクトリのファイル解凍方法について、共に勉強します.