title: Java program for reading data from file and display in predefined format
body: <p>I have a text file which is in the following format:</p>
  
  <pre><code>one,
  two,
  tree,
  four,
  five,
  six,
  ......and so on
  </code></pre>
  
  <p>Now I need a Java program which produce output in the following format:</p>
  
  <pre><code>number is one and number is two
  number is two and number is three
  number is three and number is four
  number is five and number is six
  ......and so on
  </code></pre>
  
  <p>I tried it to do in various ways but could not get the correct output.</p>
  
  <p>My code is:</p>
  
  <pre><code>public static void readData() {
      // TODO Auto-generated method stub
      File f=new File("test.txt");
      try {
          FileReader fileReader=new FileReader(f);
          BufferedReader bufferedReader=new BufferedReader(fileReader);
          String line;
          while((line=bufferedReader.readLine())!=null)
          {
              String line1[] = line.split(",");
              System.out.println("Number is : "+line1[0]+" and Number is :"+line1[1]);
          }
      } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  }
  }
  </code></pre>