-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
21 lines (20 loc) · 886 Bytes
/
Main.java
File metadata and controls
21 lines (20 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Map;
public class Main {
public static void main(String[] args) {
try {
Map<String, String> dict = Dictionary.load("src/dictionary.txt");
Translator translator = new Translator(dict);
String textForTranslation = new String(Files.readAllBytes(Paths.get("src/input.txt")));
System.out.println("Original text:\n" + textForTranslation);
String translated = translator.translate(textForTranslation);
System.out.println("Translation:\n" + translated);
} catch (InvalidFileFormatException | FileReadException e) {
System.err.println("Error: " + e.getMessage());
} catch (IOException e) {
System.err.println("Error reading file: " + e.getMessage());
}
}
}