problem printing textfields to a txt file

Hi,

I am trying to print a set of textfields to a .txt file. The code is:

//for textfield2

String s4 = (String)textField5.getValue();

s4 = "\n"+s4;

byte buf4[] = s4.getBytes();

OutputStream f4 = new FileOutputStream("C:/CreatorProjects/NewCorporateUserRegistration.prs",true);

f4.write(buf4);

f4.close();

//for textfield3

String s5 = (String)textField6.getValue();

s5 = "\n"+s5;

byte buf5[] = s5.getBytes();

OutputStream f5 = new FileOutputStream("C:/CreatorProjects/NewCorporateUserRegistration.prs",true);

f5.write(buf5);

f5.close();

I am getting all fields printed as a single line. I tried all other methods but I am unable to get them printed in separate lines.

I use to print them in separate lines in XP. Now I am running creator in vista.

Please help me.

thanks in advance...

dr.am.mohan rao

[927 byte] By [Madana] at [2007-11-26 22:40:35]
# 1

Add a newline between the lines, something like "\n" or "\r\n". What to prefer, depends on the destination platform (if this is known). You get the servers newline with

System.getProperty("line.separator")

(see API of System).

You may use a StringBuilder to avoid to open the file many times.

String ls = System.getProperty("line.separator");

StringBuilder sb = new StringBuilder();

sb.append(s4);

sb.append(ls);

sb.append(s5);

...

String export = sb.toString();

Ingmara at 2007-7-10 11:54:33 > top of Java-index,Development Tools,Java Tools...