Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //metoda pentru citirea datelor din fisier
- static ArrayList<Rute> readFile() throws IOException {
- ArrayList<Rute> x = new ArrayList<Rute>();
- Scanner filescan = new Scanner(new FileReader("rute.txt"));
- while (filescan.hasNext()) { // citirea datelor din fisier
- String nr = filescan.next();
- String nu = filescan.next();
- String pr = filescan.next();
- String lp = filescan.next();
- String ld = filescan.next();
- String ma = filescan.next();
- int a = filescan.nextInt();
- String cul = filescan.next();
- boolean c = filescan.nextBoolean();
- boolean t = filescan.nextBoolean();
- int k = filescan.nextInt();
- x.add(new Rute(nu, pr, nr, lp, ld, ma, cul, a, k, t, c));
- }
- filescan.close(); //se inchide fluxul de citire
- return x; // returnam vectorul citit
- }
- //apelarea functiei
- ArrayList<Rute> r = new ArrayList<Rute>();
- try {
- r = Rute.readFile();
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- for(Rute i: r) {
- 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');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement