Коллеги, подскажите в чем косяк?
package com.javarush.task.task31.task3110;
import com.javarush.task.task31.task3110.exception.WrongZipFileException;
import java.io.IOException;
public class Archiver {
public static Operation askOperation() throws IOException {
ConsoleHelper.writeMessage(
"Выберите операцию:\n" +
"0 - упаковать файлы в архив\n" +
"1 - добавить файл в архив\n" +
"2 - удалить файл из архива\n" +
"3 - распаковать архив\n" +
"4 - просмотреть содержимое архива\n" +
"5 - выход"
);
Operation result = null;
int order = ConsoleHelper.readInt();
result = Operation.values()[order];
return result;
}
public static void main(String[] args) {
Operation operation = null;
while (true) {
try {
operation = askOperation();
if (operation == Operation.EXIT) {
CommandExecutor.execute(operation);
break;
}
CommandExecutor.execute(operation);
} catch (WrongZipFileException e) {
ConsoleHelper.writeMessage("Вы не выбрали файл архива или выбрали неверный файл.");
} catch (IOException e) {
ConsoleHelper.writeMessage("Произошла ошибка. Проверьте введенные данные.");
} catch (Exception e) {
ConsoleHelper.writeMessage("Произошла ошибка. Проверьте введенные данные.");
}
}
}
}
//public class Archiver {
// public static Operation askOperation() throws IOException {
// ConsoleHelper.writeMessage(
// "Выберите операцию:\n" +
// "0 - упаковать файлы в архив\n" +
// "1 - добавить файл в архив\n" +
// "2 - удалить файл из архива\n" +
// "3 - распаковать архив\n" +
// "4 - просмотреть содержимое архива\n" +
// "5 - выход"
// );
// Operation result = null;
// while (true) {
// int order = ConsoleHelper.readInt();
// result = Operation.values()[order];
// if (result == Operation.EXIT) {
// break;
// }
// return result;
// }
// return result;
// }
//
// public static void main(String[] args) {
//// String stringPathArchiver = "";
//// String stringPathFileToArchive = "";
//// Operation operation;
//// try {
//// try (
//// BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in))) {
//// try {
//// stringPathArchiver = bufferedReader.readLine();
//// stringPathFileToArchive = bufferedReader.readLine();
//// } catch (IOException e) {
//// e.printStackTrace();
//// }
//// }
//// } catch (IOException e) {
//// e.printStackTrace();
//// }
////
//// ZipFileManager zipFileManager = new ZipFileManager(Paths.get(stringPathArchiver));
//// try {
//// zipFileManager.createZip(Paths.get(stringPathFileToArchive));
//// } catch (Exception e) {
//// e.printStackTrace();
//// }
////
//// ExitCommand exitCommand = new ExitCommand();
//// try {
//// exitCommand.execute();
//// } catch (Exception e) {
//// e.printStackTrace();
//// }
////
//// try {
//// ConsoleHelper.readInt();
//// } catch (IOException e) {
//// e.printStackTrace();
//// }
//
// Operation operation;
//
// // while (true) {
// try {
// operation = askOperation();
//// if (operation == Operation.EXIT) {
//// break;
//// }
// CommandExecutor.execute(operation);
// } catch (WrongZipFileException e) {
// ConsoleHelper.writeMessage("Вы не выбрали файл архива или выбрали неверный файл.");
// } catch (IOException e) {
// ConsoleHelper.writeMessage("Произошла ошибка. Проверьте введенные данные.");
// } catch (Exception e) {
// ConsoleHelper.writeMessage("Произошла ошибка. Проверьте введенные данные.");
// }
// // }
// }
//}