title: why can't I display txt file in textArea created with fxml?
body: <p>I am trying to display a txt file in a textArea contained in an anchor pane that has been created using FXML. but the file is not being displayed </p>
  
  <p>I created my own class to manage files. I have tried putting the code to display the txt file inside the initializer() but it has not worked </p>
  
  <pre><code>This is my fxml file
  </code></pre>
  
  <pre><code>&lt;AnchorPane id="MainPane" fx:id="mainPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="403.0"prefWidth="700.0"xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controller"&gt;
     &lt;AnchorPane id="notesPane" fx:id="notePanel" layoutY="53.0" 
  onDragDetected="#handleButtonAction" prefHeight="350.0" prefWidth="700.0" style="-fx-background-color: black; -fx-background-radius: 5;" visible="false"&gt;
        &lt;children&gt;
           &lt;TextArea id="notesTextArea" fx:id="notesTextArea" layoutX="179.0" layoutY="5.0" prefHeight="340.0" prefWidth="515.0" wrapText="true"&gt;
           &lt;/TextArea&gt;
        &lt;/children&gt;
     &lt;/AnchorPane&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <pre><code>This is my Java controller file
  </code></pre>
  
  <pre><code>public class Controller implements Initializable {
      private File io;
      File[] txtFile;
      String[] titles;
      Scanner reader;
  
      @javafx.fxml.FXML
      private javafx.scene.layout.AnchorPane notePanel;
      @javafx.fxml.FXML
      private javafx.scene.control.TextArea notesTextArea;
      @javafx.fxml.FXML
      private javafx.scene.layout.AnchorPane mainPane;
  
      private void initializeIO() {
          io = new File("TxtFile");
  
          String word="";
          try{
              reader=new Scanner(file);
              while (reader.hasNextLine()) {
                  word+=reader.nextLine()+"\n";
              }
          }catch (IOException error) {
  
          }
  
          String[] everything = word.split("\n");
          String txtAreaContent = "";
  
          for (String fileContents:everything) {
              txtAreaContent += fileContents + "\n";
          }
          notesTextArea.setText(txtAreaContent);
      }
  
      public void initialize(URL url, ResourceBundle rb){
          initializeIO();
      }
  }
  </code></pre>
  
  <p>The file should be added to the textArea when I load the program, however, the program runs and shows no errors but does not load the file. (the file is not empty)</p>