The Artima Developer Community
Sponsored Link

Java Answers Forum
write from text field to .txt document

1 reply on 1 page. Most recent reply: Jun 26, 2003 4:13 PM by Nicholas Partridge

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
lazza

Posts: 3
Nickname: lazza
Registered: Jun, 2003

write from text field to .txt document Posted: Jun 26, 2003 3:47 AM
Reply to this message Reply
Advertisement
Hi can anybody help,
I need the code to write from an applet textfield, to a
txt document, I only know how to write to a file from an
application.
Thanks for your help


Nicholas Partridge

Posts: 2
Nickname: nkpart
Registered: Jun, 2003

Re: write from text field to .txt document Posted: Jun 26, 2003 4:13 PM
Reply to this message Reply
There's plenty of tutorials out there on this sort thing but here's a basic set up.

You'll need to import:
java.io.FileWriter
java.io.PrintWriter

Then in your code you want to create these objects:

FileWriter fw = new FileWriter("this_string_is_the_filename");
PrintWriter pw = new PrintWriter(fw);

//now do your writing, for example:
pw.println(textfield.getText());

//After all the output is done, make sure you close the file.
pw.close();

The PrintWriter class just functions like System.out with all the print and println methods you'll ever need.

Flat View: This topic has 1 reply on 1 page
Topic: plz help me Previous Topic   Next Topic Topic: Http connection from applet

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use