title: Split a txt file into an array and find elements within the array
body: <p>Hello basically my aim is to read a <code>txt</code> file store it within an array and print the array element after the method argument. the text file is formated as shown (a space between each string on a line)</p>
  
  <pre><code>alan 1000
  
  lee 20
  
  rodney 28
  </code></pre>
  
  <p>e.g. if my argument was <code>lee</code>, the method should print out <code>20</code>. If <code>rodney</code> then <code>28</code></p>
  
  <pre><code>public class practice
  {
  public void dataReader(String fName, String pname)
  {
      try
      {
        FileReader fr=new FileReader(fName);
        BufferedReader br=new BufferedReader(fr);
  
        String[] a={};
        String line= br.readLine();
  
  
        while(line !=null)
        {
             a= line.split(" "); // deliminator white space
        }
  
        for(int i=0; i &lt;a.length; i++)
        {
            if(a[i].equals(pname))
            {
                System.out.println(a[i]+1);
            }
        }
      }
  
      catch(IOException e)
      {
      }
  }
  </code></pre>