Advertisement
Guest User

huinya liutaya

a guest
May 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.io.UnsupportedEncodingException;
  2. import java.util.*;
  3.  
  4. public class Part5 {
  5.     static Scanner scan = new Scanner(System.in);
  6.  
  7.     public static void main(String[] args) throws UnsupportedEncodingException {
  8.         ResourceBundle rbEn = ResourceBundle.getBundle("en.resources_en", new Locale("en"));
  9.         ResourceBundle rbRu = ResourceBundle.getBundle("ru.resources_ru", new Locale("ru"));
  10.         String userInput;
  11.         Map<String, ResourceBundle> bundleMap = new HashMap();
  12.         bundleMap.put("en", rbEn);
  13.         bundleMap.put("ru", rbRu);
  14.         while (!(userInput = scan.nextLine()).equals("stop")) {
  15.             String[] inputInfo = userInput.split(" ");
  16.             for (Map.Entry<String, ResourceBundle> e : bundleMap.entrySet()) {
  17.                 if (inputInfo[1].equals(e.getKey())) {
  18.                     System.out.println(e.getValue().getString(inputInfo[0]));
  19.                 }
  20.             }
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement