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();
}
}
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/
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?