3 Replies Latest reply on Dec 30, 2012 12:55 PM by Raja Pandian C

    Issue : Read a text file and print the same

    Raja Pandian C
      Hi, My requirement is to read a text file and print it the same way.

      import java.io.BufferedReader;
      import java.io.FileReader;

      public class CatFile {

      public static void main(String[] args) throws Exception
           FileReader file = new FileReader("D:/Test/Allfiles.txt");
           BufferedReader reader = new BufferedReader(file);
           String text = "";
           String line = reader.readLine();
           while (line != null)
                text += line;
                line = reader.readLine();


      The text file i used contains

      but my output is ABC.

      What change should be made to print it the same way in the txt file ?