Sergei_Langin

Sergei FlashCards Stage 7

Mar 15th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.12 KB | None | 0 0
  1. public static void main(String[] args) throws IOException {
  2.  
  3.         LinkedHashMap<String, String> hashMap = new LinkedHashMap<>();
  4.         LinkedList<String> list = new LinkedList<>();
  5.         LinkedList<Integer> list2 = new LinkedList<>();
  6.         LinkedHashMap<String, Integer> hashMap2 = new LinkedHashMap<>();
  7.         File file = new File("C:\\Users\\Plaza\\IdeaProjects\\HelloWorld\\src\\capitals.txt");
  8.         File file2 = new File("C:\\Users\\Plaza\\IdeaProjects\\HelloWorld\\src\\capitals.txt");
  9.         File file3 = new File("testLog.txt");
  10.  
  11.         if (args[0].equals("-import")) {
  12.             if (args[1].equals("capitals.txt")) {
  13.                 int N = 0;
  14.                 Scanner skaner = null;
  15.                 try {
  16.                     skaner = new Scanner(file);
  17.                     while (skaner.hasNext()) {
  18.                         String question = skaner.nextLine();
  19.                         String answer = skaner.nextLine();
  20.                         String error = skaner.nextLine();
  21.                         hashMap.put(question, answer);
  22.                         hashMap2.put(question, Integer.valueOf(error));
  23.                         N++;
  24.                     }
  25.                 } finally {
  26.                     if (skaner != null) {
  27.                         skaner.close();
  28.                     }
  29.                 }
  30.                 System.out.println(N + " cards have been loaded.");
  31.                 list.add(N + " cards have been loaded.");
  32.             }
  33.         } else if (args[0].equals("-export")) {
  34.                 if (args[1].equals("capitalsNew.txt")) {
  35.                     listaMap(hashMap, hashMap2, file2);
  36.                 } else if (args[1].equals("capitals.txt")) {
  37.                     listaMap(hashMap, hashMap2, file);
  38.                 }
  39.                 if (args[2].equals("exit")) {
  40.                     System.out.println("Bye bye!");
  41.                     System.out.println(hashMap.size() + " cards have been saved.");
  42.                     System.exit(0);
  43.                     list.add(hashMap.size() + " cards have been saved.");
  44.                     System.out.println();
  45.                 }
  46.         }
Advertisement
Add Comment
Please, Sign In to add comment