-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
44 lines (40 loc) · 1.77 KB
/
Main.java
File metadata and controls
44 lines (40 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import consoleapplication.MainInterface;
import consoleapplication.workwithroute.ParsedObjectToListRoute;
import route.Route;
import workwithexternaldata.JSONToParsedObject;
import workwithexternaldata.parsedobjects.ParsedObject;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
/**
* Main class which contains a single method which reads data from file and starts console interface
*/
public class Main {
public static void main(String[] args) throws IOException {
List<Route> data = new LinkedList<>();
try {
if (!(new File(System.getenv("Lab5Data")).exists())) {
throw new RuntimeException("Файла данных не существует");
}
if ( !(new File(System.getenv("Lab5Data")).canWrite() && new File(System.getenv("Lab5Data")).canRead())) {
throw new RuntimeException("Ввод или вывод в данный файл не доступен");
}
ParsedObject parsedObject = new JSONToParsedObject().parseFile(System.getenv("Lab5Data"));
data = ParsedObjectToListRoute.convertToListRoute(parsedObject);
}
catch (NullPointerException exn) {
System.out.println("Заданная переменная окружения отсутствует");
}
catch (FileNotFoundException fnf) {
System.out.println("Файл недоступен");
}
catch (RuntimeException exc) {
System.out.println(exc.getMessage());
}
MainInterface mainInterface = new MainInterface();
mainInterface.startMainInterface(data, () -> new Scanner(System.in).nextLine());
}
}