title: Reading lines of data from text files using java
body: <p>I have a text file with x amount of lines. each line holds a integer number. When the user clicks a button, an action is performed via actionlistener where it should list all the values as displayed on the text file. However, right now I have linenum set to 10 implying I already told the code that just work with 10 lines of the text file. So, if my text file has only 3 rows/lines of data...it will list those lines and for rest of the other 7 lines, it will spit out "null". </p>
  
  <p>I recall there is a way to use ellipsis to let the program know that you don't know the exact value but at the end it calculates it based on the given information. Where my given information will the number of lines with numbers(data). </p>
  
  <p>Below is part of the code. </p>
  
  <pre><code>private class thehandler implements ActionListener{     
  public void actionPerformed(ActionEvent event){
  BufferedReader inputFile=null;          
  try {
      FileReader freader =new FileReader("Data.txt");
      inputFile = new BufferedReader(freader); 
  
      String MAP = "";
      int linenum=10;
      while(linenum &gt; 0)
          { 
      linenum=linenum-1; 
      MAP = inputFile.readLine();//read the next line until the specfic line is found 
  
      System.out.println(MAP);
      }
  
      } catch( Exception y ) {    y.printStackTrace();    } 
  
  }}  
  </code></pre>