saving the contents of diff text fields on a frame

i want to save the contents of diff text fields on a frame in the form of a text file,using filechooser's saveDialog property for saving at a particular desination.how should i convert the values in labels and text fields so that they get saved in a text file.thnx in
[299 byte] By [javaIndiaa] at [2007-11-27 2:54:50]
# 1

Euh... depending on how you want to write it, you can do something like this:

BufferedWriter writer = new BufferedWriter(new FileWriter(new File("c:/output.txt")));

writer.write(label1.getText(), 0, label1.getText().length() - 1);

writer.write(label2.getText(), 0, label2.getText().length() - 1);

writer.write(textfield1.getText(), 0, textfield1.getText().length() - 1);

writer.write(textfield2.getText(), 0, textfield2.getText().length() - 1);

writer.close();

Additionally, you can add enters between these lines, for example:

writer.write("\n");

I haven't tested it, but see this as a hint :)

Nemesish3da at 2007-7-12 3:30:58 > top of Java-index,Desktop,Core GUI APIs...
# 2
thanks for the reply , but when i am using that unhandeled IO exception error comes, so plz tell me which file should i include(import) orwhich class to extend?
javaIndiaa at 2007-7-12 3:30:59 > top of Java-index,Desktop,Core GUI APIs...
# 3

Did you put it in a try-catch statement?

try {

// Code above

}

catch(Exception ex) {

ex.printStackTrace();

}

I don't know out of my head what you have to import and where it is located. Most IDE's have an auto-import functions, but if you do not have it check where it is located in the API:

http://java.sun.com/javase/6/docs/api/

Nemesish3da at 2007-7-12 3:30:59 > top of Java-index,Desktop,Core GUI APIs...