0
최근 질문을 살펴 보았지만 문제에 대한 해결책을 찾을 수 없습니다. 나는 모든 내용 (기본적으로 텍스트 파일)을 포함하는 여러 디렉토리를 포함하는 디렉토리를 압축해야합니다. 우편 번호를 열면 동일한 디렉토리 목록을 다시 가져 오려고합니다.Windows 디렉터리를 zip 파일로 유지
내 문제는 콘텐츠를 압축 할 수 있지만 내 zip 파일 중 하나가 일반 파일 (디렉터리 없음)으로 나오거나 손상된 것입니다. 아무도이 짓을 한거야?
내가 게시하는 코드가 손상되었거나 겉으로보기에는 빈 우편 번호를 생성하고 있습니다. 여기에 내가 해결책을 발견 addDir
File[] files = dirObj.listFiles();
byte[] tmpBuf = new byte[1024];
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
addDir(files[i], out);
continue;
}
FileInputStream in = new FileInputStream(files[i].getAbsolutePath());
System.out.println(" Adding: " + files[i].getAbsolutePath());
out.putNextEntry(new ZipEntry(files[i].getAbsolutePath()));
int len;
while ((len = in.read(tmpBuf)) > 0) {
out.write(tmpBuf, 0, len);
}
out.closeEntry();
in.close();
}
홈페이지
zipDir(filename, properties);
중복 가능성 [java.util.zip - 재생성 디렉토리 구조 (http://stackoverflow.com/questions/1399126/java-util-zip-recreating-directory-structure) –
I는 솔루션을 가지고 , 그러나 나는 아직 그것을 게시 할 수 없다. 나는 내일 게시 할 것이다. – Jeff