Writing to Files (I/O) Simple question.

M

morc

Hey,
i have this code:

String file = application.getRealPath("/") + "registered.txt";
FileWriter outW = new FileWriter(file, true);
outW.write("*T --------------------- \n"
// +"User ID: "+user_id+"\n"
+"email: "+email+"\n"
);
outw.close();


and it works fine. The only thing is i want it to overwrite whatever is
previously written in registered.txt.
i do not recall how to do this an couldn't figure it out int he
documentation.
if you can help me ill thank you in advance.
-morc
 
?

=?ISO-8859-1?Q?Asbj=F8rn?= L. Johansen

Hey,
i have this code:

String file = application.getRealPath("/") + "registered.txt";
FileWriter outW = new FileWriter(file, true);
outW.write("*T --------------------- \n"
// +"User ID: "+user_id+"\n"
+"email: "+email+"\n"
);
outw.close();

Change line 2 to:
FileWriter outW = new FileWriter(file, false);
and it works fine. The only thing is i want it to overwrite whatever is
previously written in registered.txt.
i do not recall how to do this an couldn't figure it out int he
documentation.
if you can help me ill thank you in advance.

http://java.sun.com/j2se/1.5.0/docs...er.html#FileWriter(java.lang.String, boolean)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,685
Members
48,796
Latest member
Greg L.

Latest Threads

Top