i'm having some trouble with objectinputstream. i wanted to know if it is possible to validate whether the contents are string or integers then i also wanted to ask how i could convert the contents to int [].

For the latter i tried converting it to char [] first converting to int [] in a for loop but failed.

Appreciate any assistance


You can read the object first and you the following check to see if its an instance of String or Integer class.

if(object instanceof String)
if(object instanceof Integer)

and then you can convert using casting.

String a= (String)object