title: How to store strings of text files for later use in Java
body: <p>Please forgive me, I'm relatively new to Java.</p>
  
  <p>Basically I'm wanting to get some string for a text file for later use after selecting the file through a filechooser.</p>
  
  <p>This is a snippet of the code that I have written so far. </p>
  
  <pre><code>public void actionPerformed(ActionEvent e){
      if(e.getSource() == openButton){
          returnVal = fileChooser.showOpenDialog(null);
          if(returnVal == JFileChooser.APPROVE_OPTION){
              file = fileChooser.getSelectedFile();
  
              //read file
              try{
                  br = new BufferedReader(new FileReader(file));
                  while((currentLine = br.readLine()) != null){
                      if(currentLine.startsWith(organismId)){
                     // if(Character.isDigit(currentLine.charAt(7))){
                      System.out.println(currentLine);
                  }}
              } catch (Exception error){
                  error.printStackTrace();
              }
          }
      }
  }
  </code></pre>
  
  <p>Basically I have a variable (organismId) which is determined by user input through a GUI. From this I can print out the lines which begin with the chosen String variable. However this isn't exactly what I want to achieve. I want to be able to gather the text that is present on the next line, until a character ">" is reached. </p>
  
  <p>I then want to be able to get an average character length for the text for each different organismId (i.e. >ggo and >hba).</p>
  
  <p>I.e. an example of what the text file may look like is as follows:</p>
  
  <p>>ggo</p>
  
  <p>This is an example sentence</p>
  
  <p>>ggo</p>
  
  <p>This is another example sentence</p>
  
  <p>>ggo</p>
  
  <p>This is a further example sentence which is extremely long and can go onto more than one line as is demonstrated here</p>
  
  <p>>hba</p>
  
  <p>This is a sentence with a different organismId</p>
  
  <p>I hope that all of this makes sense and any help would be much appreciated. </p>
  
  <p>Many Thanks! :)</p>