@Override public void initialize(URL location, ResourceBundle resources) { // To się wykona zaraz po uruchomieniu aplikacji i załadowaniu widoku startApp(); } List albums = new ArrayList<>(); @FXML void loadData(MouseEvent event) throws FileNotFoundException { File file = new File("Data.txt"); Scanner scanner = new Scanner(file); String[] tab = new String[5]; List albums = new ArrayList<>(); int i = 0; while (scanner.hasNextLine()) { String line = scanner.nextLine(); if (line.isEmpty()){ System.out.println("empty"); albums.add(new Albums(tab[0],tab[1], Integer.parseInt(tab[2]), Integer.parseInt(tab[3]), Integer.parseInt(tab[4]))); i = 0; }else { tab[i] = line; i++; } } System.out.println(albums.get(0).album); }