Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- public class CteniZeSouboru {
- private final static String ODDELOVAC = ";";
- private final static String SOUBOR = "Soubor.txt";
- private List<Deskovky> listGamesek = new ArrayList<>();
- public void vypis(){
- try {
- Scanner scanner = new Scanner(new BufferedReader(new FileReader(SOUBOR)));
- listGamesek.clear();
- while (scanner.hasNextLine()){
- String radek = scanner.nextLine();
- String[] casti = radek.split(ODDELOVAC);
- String nazev = casti[0];
- int oblibenost = Integer.parseInt(casti[1]);
- boolean zakoupeno = Boolean.parseBoolean(casti[2]);
- Deskovky gamesky = new Deskovky(nazev, oblibenost,zakoupeno);
- listGamesek.add(gamesky);
- }
- scanner.close();
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
- public List<Deskovky> getListGamesek() {
- return listGamesek;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement