Posted By:
cdulla_cdulla
Posted On:
Tuesday, February 18, 2003 02:31 PM
Hi, I am reading each line from file and writing into another file ... It is writing continously in the file even if i use for new line ... Why " " is not working by the time writing text into file ... Here is my code: import java.io.*; import java.net.*; import java.util.*; public class Test11{ private BufferedReader data; private String line=null; private StringBuffer buf= new StringBuffer(); private BufferedWriter thewriter=null; private File file=null; private FileReader fr=null; private String inputL
More>>
Hi,
I am reading each line from file and writing into another file ...
It is writing continously in the file even if i use
for new line ...
Why "
" is not working by the time writing text into file ...
Here is my code:
import java.io.*;
import java.net.*;
import java.util.*;
public class Test11{
private BufferedReader data;
private String line=null;
private StringBuffer buf= new StringBuffer();
private BufferedWriter thewriter=null;
private File file=null;
private FileReader fr=null;
private String inputLocation="c:\test14.txt";
public Test11(){ }
public void disp(){
try {
file=new File(inputLocation);
fr = new FileReader(file);
data = new BufferedReader(fr);
while ((line = data.readLine()) != null) {
buf.append(line + "
");
}
String text=buf.toString();
thewriter = new BufferedWriter(new FileWriter("c:\test15.txt"));
thewriter.write(text);
buf=null;
thewriter.close();
} catch(IOException e) { System.out.println("error ==="+e ); }
}
public static void main(String[] args) {
Test11 t=new Test11();
t.disp();
System.out.println("all files are converted...");
}
}
I used "
" after reading each line .. i want output file also same as input file ... how do i break each line by the time writing into text file .. "
" is working in word pad but now working in notepad ... in note pad i am getting some thing like rectangle insted of "
" ....
Any help please .....
thanks.
<<Less