안드로이드 개발 질문/답변
(글 수 45,052)
public void unzip(File zipFile, File targetDir) throws Exception { FileInputStream fis = null; ZipInputStream zis = null; ZipEntry zentry = null; //ArrayList<String> files = new ArrayList<String>(); try { fis = new FileInputStream(zipFile); // FileInputStream zis = new ZipInputStream(fis); // ZipInputStream while ((zentry = zis.getNextEntry()) != null) { String fileNameToUnzip = zentry.getName(); File targetFile = new File(targetDir, fileNameToUnzip); unzipEntry(zis, targetFile); else{ continue; } } } finally { if (zis != null) { zis.close(); } if (fis != null) { fis.close(); } } }
현재 다음과 같이,
ZipInputStream 을 통해 압축을 하나씩 풀고 있는데요,
zis.getNextEntry() 와 같이 압축된 파일중 제일 처음 파일부터 참조하는것이 아니라,
파일명을 가지고 그 파일이 있는 곳부터 참조해
압축을 풀고싶은데, 이런 방법은 없나요;
파서로 치면 DOM파서 같이
원하는 정보만 뺴내고 싶습니다.
답변 부탁드려요 ㅠㅠ;
This class provides random read access to a ZIP-archive file.
While
ZipInputStream
provides stream based read access to a ZIP-archive, this class implements more efficient (file based) access and makes use of the central directory within a ZIP-archive.