0
BufferedReader reader = new BufferedReader(new FileReader(strPath));
 String line;
 while ((line = reader.readLine()) != null) 
 { 
   
     out.println(line);
 }

My textfile is like:

Statement1
Statement2
Statement3

the output i get is:

Statement1Statement2Statment3

I need the output as it is..same as the text file...i have tried to identify the newline charc as \n or \r or \n\r and then compare it.

if(line.equals("\n")
out.println("\n")

ALSO tried

if(line.equals("")
out.println("\n")

Nothing seems to work...Please need help...i have tried using the read() for charac by charac and still i am not getting it :( :(

2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by neo_31591
0
BufferedReader reader = new BufferedReader(new FileReader(strPath));
 String line;
 while ((line = reader.readLine()) != null) 
 { 
   
     System.out.println(line + "\n");
 }

Edited by Anyday: n/a

0
BufferedReader reader = new BufferedReader(new FileReader(strPath));
 String line;
 while ((line = reader.readLine()) != null) 
 { 
   
     System.out.println(line + "\n");
 }

I am going to shoot myself, really.

I tried the above code like a million times myself before posting it here, only to get the same wrong format

literally banged my head on the wall, cause couldnt figure out what was wrong.

had a brainwave, what was missing was

out.println("<pre>")

I am really very sorry to have wasted your time, with this utter silly mistake for which i really wanna kill myself :( :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.