title: retrieve phone number from text file using indexOf
body: <p>I have a <code>text file</code> which has details like <code>date</code>,<code>time</code>,<code>phone number</code>, etc. I am trying to retrieve these details using the <code>java</code> <code>indexOf</code> concept. However, the <code>digits</code> in the <code>phone number</code> would change depending on the type of call.</p>
  
  <p>How can I improve the code so I am able to retrieve every <code>phone number</code> from the file. Here's what I've been trying : </p>
  
  <pre><code>BufferedReader reader = new BufferedReader(new FileReader(filePath));
              String getIndex="";
  while ((line = reader.readLine()) != null) {
  
       line = line.replaceAll("[\\s]+", " ");   //remove all large spaces from the file.
  
      /*
           the dialledNo is chosen with the help of a combo box.
           calculating the start and end index in order to print the dialled no.
          */
  
      int startIndex = getIndex.indexOf(dialledNo);
  
      int endIndex = getIndex.indexOf(" ", startIndex);
  
      strDialedNo= (startIndex + "," + endIndex);
  </code></pre>
  
  <p>And the code to retrieve the number is mentioned below :</p>
  
  <pre><code>String[] arrDialedNo = strDialedNo.split(",");
  
  int DialedNoStart = Integer.parseInt(arrDialedNo[0]);
  int DialedNoEnd = Integer.parseInt(arrDialedNo[1]);
  
  DialedNo = line.substring(DialedNoStart, DialedNoEnd);
  </code></pre>
  
  <p>This is how my text file looks like:</p>
  
  <pre><code>0356  524           000   8861205063        12/03 18:59    00:08     01:20
  0357  524           000   9902926868        12/03 20:01     
  0373  511           000   09886863637       13/03 11:46    01:01     02:40  S
  0376  504           000   9845014967        13/03 11:46    00:11     01:20
  0382  508           000   04443923200       13/03 12:04    03:11     04:80  S
  0411  516           000   8884103111        13/03 16:25    01:03     01:20
  </code></pre>