Hi just wanted to know a simple way of writing on a file whatever is written on the textfield after pressing a button. I would really appreciate any help on this one. thanks!
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi just wanted to know a simple way of writing on a file whatever is written on the textfield after pressing a button. I would really appreciate any help on this one. thanks!
See the PrintWriter class for writing text to a file.
If you don't understand my answer, don't ignore it, ask a question.
hawkeye01 (March 24th, 2013)
I found this very simple application for the PrintWriter.
// Demonstrate PrintWriter import java.io.*; public class PrintWriterDemo { public static void main(String args[]) { PrintWriter pw = new PrintWriter(System.out, true); pw.println("This is a string"); int i = -7; pw.println(i); double d = 4.5e-7; pw.println(d); } }
So I just set the file name on the PrintWriter, but how do I copy the string on the Jtextfield?
Read the API doc for the JTextfield class. It has a method for getting the text it contains as a String.how do I copy the string on the Jtextfield?
If you don't understand my answer, don't ignore it, ask a question.