Я использую механизм Java для извлечения 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();
}
Вылетает на while((currentByte = is.read(data, 0, BUFFER)) != -1)
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)
Известны ли вам какие-либо обходные пути для решения этой проблемы? Могу ли я изменить имя файла внутри zip, не распаковывая его?