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 :)
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/