Guest User

Untitled

a guest
Jul 16th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package prikladek;
  6.  
  7. import java.io.*;
  8. import java.util.Arrays;
  9. import java.util.TreeMap;
  10.  
  11. /**
  12.  *
  13.  * @author Tom
  14.  */
  15. public class Prikladek {
  16.  
  17.     /**
  18.      * @param args the command line arguments
  19.      */
  20.     public static void main(String[] args) throws FileNotFoundException, IOException {
  21.        
  22.         TreeMap<String, Integer> map = new TreeMap<String, Integer>();
  23.         BufferedReader rd = new BufferedReader(new FileReader("tabulka.txt"));
  24.         String s;
  25.         while ((s = rd.readLine()) != null) {
  26.             String[] pole = s.split("[\t]");
  27.             map.put(pole[0], Integer.parseInt(pole[1]));
  28.         }
  29.         rd.close();
  30.         System.out.println(map);
  31.  
  32.         BufferedReader rd2 = new BufferedReader(new FileReader("zprava.txt"));
  33.         String vstup = rd2.readLine();
  34.         String retezec = "";
  35.         for (int i = 0; i < vstup.length(); i++) {
  36.             retezec += String.valueOf(map.get(String.valueOf(vstup.charAt(i)))) + " ";
  37.         }
  38.         System.out.println(retezec);
  39.  
  40.         rd2.close();
  41.  
  42.  
  43.     }
  44. }
Add Comment
Please, Sign In to add comment