Appending a "\n" to a file created.
I am reading database column values and writing it to a file.
I want to add a "\n" after each line is read,but even if I
append a "\n" to the file,the file output comes all on
the same line.
How do I add the "\n" to the values read so that the output looks like
RDB,234567,4567
LON,345677,8970
EUR,456880,9833
This is my code :
try{
FileWriter fWrite =new FileWriter("/JavaWorks/OS1.txt",true);
for (int i = 0; i < rowCount; i++ ){
Object entity = stm_OS.getValueAt(i, stm_OS.getColumnIndex("id_entity"));
Object ca= stm_OS.getValueAt(i, stm_OS.getColumnIndex("id_ca"));
Object inst= stm_OS.getValueAt(i, stm_OS.getColumnIndex("id_inst"));
String source = entity .toString()+"," +
ca.toString()+"," +
inst.toString()+"," +"\n";// putting "\n" here doesnt help.
char buffer[] =newchar[source.length()];
source.getChars(0,source.length(),buffer,0);
for(int b=0; b<buffer.length; b++){
fWrite.write(buffer[b]);
}
}
}catch(Exception e){}
>

