I was wondering since FileInputStream and FileOutputStream have constructors that take file object, to simplify/streamline ones design,
1. can File I/O Streams handle the job when Object I/O Streams are typically used?
2. if not, is there some sort of rule of thumb as to when one must use the Object I/O Streams, and not File I/O Streams?
ObjectOutputStream/ObjectInputStream are for primarily for serializing/deserializing objects when you want to persist objects to/from local storage, or when transferring objects between applications/platform through a network.
Yes I have. You just like to get on my case, don't you?
But Ron had it pegged. I was hoping that maybe there was a way that I could design an application that didn't have to have so many different types of Streams, since it has to both handle raw bytes and persist objects with local storage involved and on top of that transferring them (both raw bytes and objects) to remote storages.
I think it is called the decorator pattern, but I might be mistaken. The whole idea of the design of the java.io package is a response to the fact that there are all sorts of different sources of information, and when you get there, you find that the information is in all sorts of different formats. So each class is intended to work with a particular source with information in a particular format. The different formats are handled by different classes at the back end.
The same sort of thing applies to outputs.
I think it is called the decorator pattern, but I might be mistaken
As usual you are not mistaken. I looked into decorator design pattern and some examples online, and changing the design from abstract's IS-A to decorator pattern's HAS-A, hence modifying each I/O component behavior, saved me a lot of back and forth and much closer to the so-called streamlining the overall code that I was looking to do.
Jake Monhan wrote:. . . As usual you are not mistaken. . . .
I make lots of mistakes.
Thanks a bunch.
That's a pleasure If you find a copy of Core Java II by Cay Horstmann or by Cay Horstmann and Gary Cornell, the IO chapter shows some of the combinations of classes you can use to read and write files etc. There were major changes in Java7 (2009).