Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Writing to Files (I/O) Simple question.

Thread view: 
morc - 01 Feb 2006 21:36 GMT
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
Asbjørn "L. Johansen" - 01 Feb 2006 22:01 GMT
> Hey,
> i have this code:
[quoted text clipped - 6 lines]
>                     );
>             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/api/java/io/FileWriter.html#FileWriter(java.
lang.String,%20boolean
)
--
Asbjørn L. Johansen
asbjorjo@stud.ntnu.no


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.