I have an ObjectInputStream which needs to read two different inputs which are a String and my own created object. I have a thread which constantly waits for an input and depending on the input be it a string or object it will process the result. I need a way for the input to be able to distinguish between the two.
Any help would be great.
Thanks
Isn't it a case of doing:
if (objectFromStream instanceof YourObejct) {
YourObject obj = (YourObject) objectFromStream;
....
} else if (objectFromStream instanceof String) {
String str = (String) objectFromStream;
} else {
// throw excepption..
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With