Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. //metoda pentru citirea datelor din fisier
  2. static ArrayList<Rute> readFile() throws IOException {
  3.  
  4. ArrayList<Rute> x = new ArrayList<Rute>();
  5. Scanner filescan = new Scanner(new FileReader("rute.txt"));
  6.  
  7. while (filescan.hasNext()) { // citirea datelor din fisier
  8. String nr = filescan.next();
  9. String nu = filescan.next();
  10. String pr = filescan.next();
  11. String lp = filescan.next();
  12. String ld = filescan.next();
  13. String ma = filescan.next();
  14. int a = filescan.nextInt();
  15. String cul = filescan.next();
  16. boolean c = filescan.nextBoolean();
  17. boolean t = filescan.nextBoolean();
  18. int k = filescan.nextInt();
  19.  
  20. x.add(new Rute(nu, pr, nr, lp, ld, ma, cul, a, k, t, c));
  21. }
  22. filescan.close(); //se inchide fluxul de citire
  23. return x; // returnam vectorul citit
  24. }
  25.  
  26. //apelarea functiei
  27. ArrayList<Rute> r = new ArrayList<Rute>();
  28. try {
  29. r = Rute.readFile();
  30. } catch (IOException e1) {
  31. e1.printStackTrace();
  32. }
  33.  
  34. for(Rute i: r) {
  35. System.out.print(i.nr_ruta + " " + i.nume + " " + i.prenume + " " + i.loc_p + " " + i.loc_d + " " + i.marca_auto + " " + i.an + " " + i.culoarea + " " + i.cond + " " + i.tv + " " + i.km + '\n');
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement