Попробуйте применить try_resources с ошибками компиляции [дубликат]JAVA

Программисты JAVA общаются здесь
Anonymous
Попробуйте применить try_resources с ошибками компиляции [дубликат]

Сообщение Anonymous »

Я пытаюсь применить try_resources:

Код: Выделить всё

    public ReferenceGroup forEach(ZipEntryConsumer zipEntryConsumer) {
ReferenceGroup referenceGroup = null;
try (InputStream s3ResourceInputStream = this.s3Resource.getInputStream(); ZipInputStream zipInputStream = new ZipInputStream(s3ResourceInputStream)) {
LocalFileHeader localFileHeader;
while ((localFileHeader = zipInputStream.getNextEntry()) != null) {
Path path = Paths.get(localFileHeader.getFileName());
boolean isDirectory = localFileHeader.isDirectory();

referenceGroup = zipEntryConsumer.accept(zipInputStream, path, isDirectory);
}
}

return referenceGroup;
}
Однако я получаю:

Код: Выделить всё

 │     Unhandled exception type IOException thrown by automatic close() invocation on s3ResourceInputStream Java (16778098) [28, 20]
│     Unhandled exception type IOException Java (16777384) [28, 44]
│     Unhandled exception type IOException thrown by automatic close() invocation on zipInputStream Java (16778098) [28, 93]
│     Unhandled exception type IOException Java (16777384) [30, 31]
Я не совсем понимаю, что я делаю не так, есть идеи?

Подробнее здесь: https://stackoverflow.com/questions/781 ... ile-errors

Вернуться в «JAVA»