Advertisement
Guest User

Untitled

a guest
Mar 9th, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1.  
  2. import java.io.BufferedReader;
  3. import java.io.FileNotFoundException;
  4. import java.io.FileReader;
  5. import java.io.IOException;
  6. import java.util.Map;
  7. import java.util.HashMap;
  8.  
  9. public class Quiz_main {
  10.  
  11.     public static void main(String[] args) {
  12.  
  13.         FileReader file = null;
  14.         String linia = "";
  15.         String linia2 = "";
  16.         String linia3 = "";
  17.         String tab[][] = new String[10][10];
  18.         int licznik = 0;
  19.         // OTWIERANIE PLIKU:
  20.         try {
  21.             file = new FileReader("Pytania.txt");
  22.         } catch (FileNotFoundException e) {
  23.             System.out.println("BŁĄD PRZY OTWIERANIU PLIKU!");
  24.         }
  25.  
  26.         BufferedReader buffor = new BufferedReader(file);
  27.         Map<String, String> quizMap = new HashMap<String, String>();
  28.  
  29.         // ODCZYT KOLEJNYCH LINII Z PLIKU:
  30.         try {
  31.             while ((linia = buffor.readLine()) != null) {
  32.                 switch (licznik) {
  33.                   case 0:
  34.                     {
  35.                         linia2=linia;
  36.                         licznik++;
  37.                     }
  38.  
  39.                   case 1:
  40.                     {
  41.                         linia3=linia;
  42.                         licznik=0;
  43.                         String quizQA = quizMap.put(linia2,linia3);
  44.                     }
  45.  
  46.                   default:
  47.                     System.out.println("blad");
  48.                 }
  49.  
  50.  
  51.             }
  52.         } catch (IOException e) {
  53.             System.out.println("BŁĄD ODCZYTU Z PLIKU!");
  54.         }
  55.         // ZAMYKANIE PLIKU
  56.         try {
  57.             file.close();
  58.         } catch (IOException e) {
  59.             System.out.println("BŁĄD PRZY ZAMYKANIU PLIKU!");
  60.         }
  61.  
  62.         System.out.println(quizMap);
  63.  
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement