Advertisement
_RichY

Untitled

Jan 12th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. public class Main {
  2.  
  3.     /**
  4.      * @param args the command line arguments
  5.      */
  6.     public static void main(String[] args) throws FileNotFoundException, IOException {
  7.         File fajl = new File("D:\\Erettsegi\\Info\\Forrasok\\4_Otszaz\\penztar.txt");
  8.         RandomAccessFile raf = new RandomAccessFile(fajl, "r");
  9.        
  10.         ArrayList<String> beolv = new ArrayList<String>();
  11.         String be = "";
  12.        
  13.         ArrayList<tranzak> trs = new ArrayList<tranzak>();
  14.        
  15.         be = raf.readLine();
  16.        
  17.         while(be != null) {
  18.             beolv.add(be);
  19.             be = raf.readLine();
  20.         }
  21.        
  22.         int index = 1;
  23.         ArrayList<String> temp = new ArrayList<String>();
  24.         tranzak temptranz = new tranzak(0, temp);
  25.         for (int i = 0; i <= beolv.size()-1; i++) {
  26.             if (beolv.get(i).equals("F")) {
  27.                 temptranz.id = index;
  28.                 System.out.println(temptranz.id);
  29.                 System.out.println(temptranz.term);
  30.                 //Idáig minden OK, szépen megkapja a tranzakció az azonosítóját és a terméklistát
  31.                 trs.add(temptranz);
  32.                 //Beállítom a változókat a következő tranzakcióhoz
  33.                 ind++;
  34.                 temptranz.id = 0;
  35.                 temptranz.term.clear();
  36.             } else {
  37.                 temptranz.addTerm(beolv.get(i));
  38.             }
  39.         }
  40.        
  41.        
  42.         //Viszont amikor kiiratnám a végleges tranzakciólistát már rossz ID-t és üres terméklistát kapok vissza
  43.         for (int i = 0; i <= trs.size()-1; i++) {
  44.             System.out.println(trs.get(i).id);
  45.             System.out.println(trs.get(i).term);
  46.         }
  47.        
  48.     }
  49.    
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement