Hook up an ObjectOutputStream to a corresponding ObjectInputStream

  • Thread starter Thread starter 0rthodontist
  • Start date Start date
Click For Summary
SUMMARY

To connect an ObjectOutputStream to a corresponding ObjectInputStream in Java without using a socket, the solution involves utilizing PipedOutputStreams. This approach allows for the abstraction of data streams while maintaining the necessary connections between objects. The user initially considered direct references for neighbor interactions but opted for the stream-based solution to enhance abstraction.

PREREQUISITES
  • Understanding of Java I/O streams
  • Familiarity with ObjectOutputStream and ObjectInputStream classes
  • Knowledge of PipedOutputStream and PipedInputStream
  • Basic object-oriented programming concepts in Java
NEXT STEPS
  • Explore Java PipedOutputStream and PipedInputStream documentation
  • Learn about Java serialization and deserialization processes
  • Investigate design patterns for object communication in Java
  • Study advanced Java I/O techniques for stream handling
USEFUL FOR

Java developers, software engineers, and anyone interested in implementing object communication through streams in Java applications.

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:

Similar threads

  • · Replies 18 ·
Replies
18
Views
2K
Replies
18
Views
3K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 15 ·
Replies
15
Views
3K
Replies
40
Views
5K
Replies
8
Views
6K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K