Click to See Complete Forum and Search --> : How to save string from a JTextBox to a file?


mblichew
10-24-2005, 05:19 AM
Just like in topic - i'm quite newbie in java programming and I'm interested to do a simple program(with JForm) that will save text from a JTextBox to a file(can be in text format but I prefer it to be saved in a binary format). Then, after writing file name into one JTextBox program will show this text in another JtextBox or JLabel. Eyery example that I found uses StreamReader class (with standard stream input System.in).
I know that there is RandomAccessFile class but I don't know which method(s) should I use. Can anyone write a short exaple for me:)? I would be grateful,
thanks in advance

BigDog
10-24-2005, 04:21 PM
You basically need just plain old Java IO, there is nothing special about doing it from a GUI. A bunch of good examples are here http://javaalmanac.com/egs/java.io/pkg.html

If what you are trying to save is just a text file, i recomment saving it in text instead of binary. If you are trying to save an entire object, then you would want to look into serialization, which the link I provided also has examples on.