저는 Java 메커니즘을 사용하여 zip 파일을 추출합니다. 제목에 액센트가있는 파일이 없으면 메커니즘이 잘 작동합니다. 포르투갈 출신 이래로, ç, ç, õ, é 등과 같은 문자는 대개 제 언어로 사용됩니다. 이 문자 중 하나라도 파일 이름에 있으면 IO 예외가 발생합니다.악센트가있는 zip 파일의 압축 해제
while (zipFileEntries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) zipFileEntries.nextElement();
File destFile = new File(unzipDestinationDirectory, currentEntry);
File destinationParent = destFile.getParentFile();
// create the parent directory structure if needed
destinationParent.mkdirs();
// extract file if not a directory
if (!entry.isDirectory()) {
BufferedInputStream is =
new BufferedInputStream(zip_file.getInputStream(entry));
int currentByte;
byte data[] = new byte[BUFFER];
// write the current file to disk
FileOutputStream fos = new FileOutputStream(destFile);
BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER);
// read and write until last byte is encountered
while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
dest.write(data, 0, currentByte);
}
dest.flush();
dest.close();
is.close();
}
그것은이 문제를 해결하기 위해 어떤 해결 방법을 알고 있습니까
java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:134)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
at parsers.ZipParser.decompressZipFile(ZipParser.java:83)
at poc.MainPOC.main(MainPOC.java:61)
while((currentByte = is.read(data, 0, BUFFER)) != -1)
에 충돌? 압축 해제하지 않고 압축 파일 안의 파일 이름을 변경할 수 있습니까?
저는 입력 zip 파일을 만드는 책임자가 아닙니다. 나는 zip 파일이 어떻게 생성되는지에 어떤 영향도 미치지 않습니다 ... – nunoaac
당신은 그 영향력을 찾아야 만합니다. 그렇지 않으면 효과가 없습니다. 아마도 당신은 그들을 만들고있는 파트너와 대화해야 할 것입니다. – duffymo
이것은 실제로 옵션이 아닙니다 :/java.util.zip을 Apache Commons IO lib로 대체합니다. – nunoaac