I'm a beginner programmer following this Java Tutorial.
In the Basic I/O section, two of the classes mentioned are Data Streams and Object Streams.
They are used very similarily:
out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(dataFile)));
// ..
in = new DataInputStream(new BufferedInputStream(new FileInputStream(dataFile)));
for DataInputStream
and
out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(dataFile)));
// ..
in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(dataFile)));
for ObjectInputStream
I know it says that DataInputStreams
are used for primitive objects, and ObjectInputStreams
are used for objects (and serialization of them), so which one should I use? It isn't a noticeable difference between the two example classes which both use primitive types. I usually use primitive types, too.
For performance, which one is better? and are there any other large differences?
thanks.