November 18, 2004

UML for the Software Developer, Part 1: Building Classes

hy do we need to model software? After all, aren’t the acts of coding and refactoring of that code enough? That depends on what is meant by enough! You could code up some software, hand it in, and go through a constant refactoring process with the client. This is how

Persist Java Objects in a File and Retrieve Them Later

For persisting Java objects in a file, use java.io.ObjectOutputStream. ObjectOutputStream writes primitive data types or Java objects. Persistent storage can be accomplished by using a file for the stream. Only serializable objects can be persisted: ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(“C:\sample.txt”));oos.writeObject(new String(“Hello my dear friends”));oos.writeInt(10);oos.writeObject(new Integer(5));oos.close(); The above code writes