help with storing text file

please can any one show me how i can save something in java as a file ?i need to store each session in calculator to the file how ?is there any example to see it how it can be .thank you so much.
[223 byte] By [Alenaa] at [2007-11-27 7:28:26]
# 1

To write the contents of a JTextArea or other JTextComponent:

void saveText(File file, JTextComponent comp) throws IOException {

Writer out = new FileWriter(file);

try {

comp.write(out);

} finally {

out.close();

}

}

Hippolytea at 2007-7-12 19:08:34 > top of Java-index,Java Essentials,Java Programming...
# 2

You can easily write to files using the stuff in the java.io package.

Plus there are many other ways to do this. The best way depends on what you're doing. Often the easiest thing is to serialize data as XML or as java.util.Properties files.

http://java.sun.com/docs/books/tutorial/essential/io/

paulcwa at 2007-7-12 19:08:34 > top of Java-index,Java Essentials,Java Programming...
# 3
thx for informationwhat i m doing.i have claculator and i need to store each session (so if i add (2+3=5)) i need to store in a file.and rename the file.there in the address u gave me i can fins something like this yes..?
Alenaa at 2007-7-12 19:08:34 > top of Java-index,Java Essentials,Java Programming...
# 4

The link to the tutorial will show you ways to do I/O, including writing to files.

Writing the "session" to a file will depend on what exactly you mean by a "session". What is in a session? What are the relationships between elements in a session? Are you going to want to load this session later into a new object?

paulcwa at 2007-7-12 19:08:34 > top of Java-index,Java Essentials,Java Programming...
# 5
like the main imporatnt thing to do is to save each calculation element.in a separate file.if u have any example just to see it.some codes.or where can i find.like u have program and u need to save some thing in a text file.
Alenaa at 2007-7-12 19:08:34 > top of Java-index,Java Essentials,Java Programming...
# 6
Have you studied the tutorial linked in reply #2?
Hippolytea at 2007-7-12 19:08:35 > top of Java-index,Java Essentials,Java Programming...
# 7
ok thx a lotand one more thing like where can find some example with codes to see how.(i know that this tutorial has to many and where else )
Alenaa at 2007-7-12 19:08:35 > top of Java-index,Java Essentials,Java Programming...
# 8
The Java Almanac has examples: http://www.exampledepot.com/
Hippolytea at 2007-7-12 19:08:35 > top of Java-index,Java Essentials,Java Programming...