Where am I going wrong?
public List<FileProperties> getFileList() throws Exception {
if (!Files.isRegularFile(zipFile)) throw new NoSuchZipFileException();
List<FileProperties> files = new ArrayList<>();
try (ZipInputStream zipInputStream = new ZipInputStream(Files.newInputStream(zipFile))) {
ZipEntry zipEntry;
while ((zipEntry = zipInputStream.getNextEntry()) != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
copyData(zipInputStream, baos);
files.add(new FileProperties(zipEntry.getName(), zipEntry.getSize(),
zipEntry.getCompressedSize(), zipEntry.getMethod()));
}
}
return files;
}
package com.codegym.task.task31.task3110;
import com.codegym.task.task31.task3110.exception.NoSuchZipFileException;
import java.io.IOException;
public class Archiver {
public static void main(String[] args) throws IOException {
Operation operation = null;
do {
try {
operation = askOperation();
CommandExecutor.execute(operation);
} catch (NoSuchZipFileException e) {
ConsoleHelper.writeMessage("You didn't select an archive or you selected an invalid file.");
} catch (Exception ex) {
ConsoleHelper.writeMessage("An error occurred. Please check the entered data.");
}
} while (operation != Operation.EXIT);
}
public static Operation askOperation() throws IOException {
ConsoleHelper.writeMessage("Select an operation:\n" +
"0 - Zip files into an archive\n" +
"1 - Add a file to an archive\n" +
"2 - Remove a file from an archive\n" +
"3 - Extract an archive\n" +
"4 - View the contents of an archive\n" +
"5 - Exit");
return Operation.values()[ConsoleHelper.readInt()];
}
}