안녕하세요 초보개발자 지바냥입니다.
현재 일반 파일을 압축한 zip 파일은 아래 소스로 압축 해제가 잘 되고 있는데요..
폴더를 압축한 zip 파일이 압축 해제가 안되고 있어 골머리를 앓고 있네요 ㅠㅠ
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
해당 퍼미션도 추가가 되어있고 뭐가 문제인지 몰라 결국 질문글을 올리게 되었습니다.
혹시 폴더가 압축된 zip파일을 해제할경우에는 다른 방식으로 해야하는 것인지 답변 부탁 드립니다 ㅠㅠ
UnZip ----------------------------------------
public void unzip(String aZipFile, String aLocation) {
try {
FileInputStream fin = new FileInputStream(aZipFile);
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
FileOutputStream fout = new FileOutputStream(aLocation + File.separator + ze.getName());
BufferedInputStream in = new BufferedInputStream(zin);
BufferedOutputStream out = new BufferedOutputStream(fout);
byte b[] = new byte[buffSize];
int n;
while ((n = in.read(b, 0, buffSize)) >= 0) {
out.write(b, 0, n);
}
zin.closeEntry();
out.close();
}
zin.close();
}
catch (Exception e) {
UtilLog.e("Asdf");
UtilLog.e("Asdf");
}
}
Activity ----------------------------------------------------------------
String dest = UtilFile.pathForResource("해제경로");
File root = new File(dest);
if (!root.exists()) {
root.mkdirs();
}
UtilDecompress unzip = new UtilDecompress();
String zipFile = UtilFile.pathForResource("파일경로");
String Path = dest;
UtilLog.e("UNZIP Start");
unzip.unzip(zipFile, Path);
UtilLog.e("UNZIP End");