You can name the files anything you want. For saving objects (not text, that is done differently but the same basics apply), just use a FileOutputStream and put it in an ObjectOutputStream. You can specify the filename and the extension (ie "hello.zzz") like this:
output = new ObjectOutputStream(new FileOutputStream("hello.zzz"));
You can save your object like this:
output.writeObject(myObjectToSave);
(Of course you can write multiple objects to the same file by repeating the above)
After you're done saving, you have to close the file, like this:
output.close();
Remember: everything you want to save, has to be serializable. A lot of standard objects (such as
String) are, but when you create your own objects and want to save these, they have to implement Serializable (don't forget to import java.io.*;!)
Opening and reading from files is done the same way:
input = new ObjectInputStream(new FileInputStream("hello.zzz"));
MyObject myObject = (MyObject) input.readObject(); (don't forget to typecast here)
input.close();
good luck.
[ February 17, 2002: Message edited by: Allard van Hooff ]