There is a button on it action, which is described by a method in another class. When I try to download a file, the application simply does not respond, and when I open the file selection window and click cancel, a bunch of errors go to the console that refer to the try line:
//главный класс loadFile.setOnAction(e -> actions.loadFile(primaryStage)); //другой класс public void loadFile(Stage window) { FileChooser fileChooser = new FileChooser(); File file = fileChooser.showOpenDialog(window); try (Scanner scanner = new Scanner(file)){ while (scanner.hasNextLine()) { } } catch (IOException ex) { System.out.println(ex.getMessage()); } }