Hook up an ObjectOutputStream to a corresponding ObjectInputStream

  • Thread starter Thread starter 0rthodontist
  • Start date Start date
AI Thread Summary
In Java, connecting an ObjectOutputStream to a corresponding ObjectInputStream without a socket can be achieved using PipedOutputStreams. This method allows for the abstraction of streams while maintaining the ability for objects to interact with their neighbors without direct references. The goal is to avoid requiring objects to have prior knowledge of their connections. The user initially sought a solution for managing object interactions more abstractly. Ultimately, the problem was resolved with the use of PipedOutputStreams.
0rthodontist
Science Advisor
Messages
1,229
Reaction score
0
In Java, I want to hook up an ObjectOutputStream to a corresponding ObjectInputStream without a socket in between. My motivation is that I'm going to have a bunch of objects with neigbhors, but the objects will be hooked up to their neighbors by a separate method (the objects should not need to have a priori knowledge of how they are hooked up). How can I do this?

I could just have each object store references to its neighbors, and have functions to interact directly with the neighbors, but I'd prefer the abstraction of a stream if it's possible.

Edit: never mind, I figured it out (PipedOutputStreams).
 
Last edited:
Back
Top