Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing info from Textfield to a file

Status
Not open for further replies.

jeremytaffy

Technical User
Sep 6, 2001
75
US
I was wondering if there is a way to write information directly from a text field to a file.
 
sure there is. open a textfile using File object.

File f=new File("some file path...");

then have some buffered writer or something. write to the file in the form of string. this string is the one from ur textbox,

something like, String s = t.getText()

sorry i dont remember the exact method to write to the file, but any basic reference material should give u that.

luv
Karthik.
 
You can also write code to serialize the object (the object with the text field) and simply write the object out to disk. you can load the serialized object easily.

//Write out the serialized objects to file
FileOutputStream file = new FileOutputStream (currFileName);
ObjectOutputStream out = new ObjectOutputStream(file);

//Write out the object
out.writeObject(idPane);

OR

File file = new File(//some file);
file.createNewFile();

// Create an output writer that will write to that file.
// FileWriter handles international characters encoding conversions.

FileWriter out = new FileWriter(file);
out.write(buffer);
out.close();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top