title: How do I use Buffered Reader to read only text, or only numbers in a txt file?
body: <p>Basically what I'm trying to do is read this text.</p>
  
  <pre>
  1591 : Dummy
  1592 : Dummy
  1593 : Dummy
  1594 : Dummy
  1595 : Dummy
  1596 : Dummy
  </pre>
  
  <p>The numbers refer to the NPC id, and the text refers to the npc name.</p>
  
  <p>I'm trying to use Buffered reader to return the npc ID and the npc name.</p>
  
  <pre><code>import java.io.IOException;
  import java.io.FileReader;
  import java.io.BufferedReader;
  
  public class ReadFile {
  
  private String path;
  
  private int id;
  
  public ReadFile(String file_path) {
      this.path = file_path;      
  }
  
  public String[] openFile() throws IOException {
  
      FileReader fr = new FileReader(path);
      BufferedReader textReader = new BufferedReader(fr);
  
      int numberOfLines = readLines();
      String[] textData = new String[numberOfLines];
  
      for (int i=0; i &lt; numberOfLines; i++) {
          textData[i] = textReader.readLine();
      }
  
      textReader.close();
      return textData;        
  }   
  
  
  int readLines() throws IOException {
  
      FileReader file_to_read = new FileReader(path);
      BufferedReader bf = new BufferedReader(file_to_read);
  
      String aLine;
      int numberOfLines = 0;
  
      while ((aLine = bf.readLine()) != null) {
          numberOfLines++;
      }
      bf.close();
      return numberOfLines;
  }
  
  }
  </code></pre>