In this Java project I'm working on for university, I have a situation where I am currently sending strings through the network successfully using
streamOut = ObjectOutputStream
streamIn = ObjectInputStream
streamOut.writeUTF(msgs.peek());
where msgs is a linked blocking queue, receiving it with
String in = streamIn.readUTF();
however, I would like to use an ObjectInputStream and an ObjectOutputStream. I have initialized them both in the constructor and I flush the ObjectOutputStream after constructing it, I read somewhere you have to do this.
I want to send both Strings and another Object type, call it gameWorld over the network (don't care about efficiency at this point).. however when I do
streamOut.writeObject("mad cuz i'm bad");
Object in = streamIn.readObject();
if(in instanceof String) String inS = (String) in;
it doesn't pick anything up when I send strings over... my friend is working on the same project and he passes around only 1 type of object, one of the subclasses of this object is essentially a string and his version works fine, but he makes a new stream in every iteration of his thread's run loop.
Do I need to do something with the stream to receive different objects which don't have a common ancestor other than Object, do I need to make a new stream every iteration of the run loop or is there just something else completely that I'm missing and the information I've provided isn't sufficient to tell whats wrong?