ZipFileManager class.
Help please!
package com.codegym.task.task31.task3110;
import com.codegym.task.task31.task3110.command.ExitCommand;
import com.codegym.task.task31.task3110.exception.NoSuchZipFileException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Paths;
public class Archiver {
public static void main(String[] args) throws IOException {
// String archivePath;
// String filePath;
// ZipFileManager zipFileManager;
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);
// try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in))) {
// System.out.print("Enter the full path to the archive: ");
// archivePath = bufferedReader.readLine();
//
// System.out.print("Enter the path to the file to be zipped: ");
// filePath = bufferedReader.readLine();
//
// zipFileManager = new ZipFileManager(Paths.get(archivePath));
// zipFileManager.createZip(Paths.get(filePath));
//
// } catch (IOException e) {
// e.printStackTrace();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
//
// ExitCommand exit = new ExitCommand();
// try {
// exit.execute();
// } catch (Exception e) { e.printStackTrace(); }
}
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()];
}
}