Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2007, 05:56 PM
Senior Member
 
Join Date: Jun 2007
Posts: 114
Albert is on a distinguished road
Problem with storing and retrieving from a textfile
I used these lines of code for getting data from text field and storing into a textfile.
But this overwrites into same place, all i want to do is storing more than one data in a same file.

Also I could not retrieve data from a text file using BufferedReader method.
Code:
//try { BufferedWriter fileOut = new BufferedWriter(new FileWriter("filename.txt")); //Create the Buffered Writer object to write to a file called filename.txt fileOut.write(myTextField.getText()); // Write to the file, using the text from our textfield fileOut.close(); // Close the output stream after all output is done. } catch (IOException ioe) { ioe.printStackTrace(); //}
Greetings.
Albert
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-13-2007, 04:01 PM
Member
 
Join Date: Jul 2007
Posts: 44
susan is on a distinguished road
You'll probably want to use .append(char c) rather than .write()

Writer (Java 2 Platform SE 5.0)
BufferedWriter (Java 2 Platform SE 5.0)

Another way (besides what Gox has written) is when you create the new FileWriter is to add a boolean of true for appending.

Code:
import java.io.*; public class test { public static void main (String args[]) throws IOException { BufferedWriter stdout = new BufferedWriter(new FileWriter("file.txt", true)); } }
That will always append to the end when you do stdout.write("something");
FileWriter (Java 2 Platform SE 5.0)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search TextFile gsupriyarao@yahoo.com Advanced Java 5 04-11-2008 12:03 PM
storing and retrieving a file as such anil_manu Advanced Java 0 03-11-2008 02:27 PM
reading textfile from java problem saytri New To Java 1 01-17-2008 03:13 AM
Storing Data Khorod New To Java 1 08-03-2007 06:48 AM
ECG plot in a textfile samson Java 2D 1 07-17-2007 04:53 AM


All times are GMT +3. The time now is 12:40 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org