1

How to deserialize an Object without file input.

I have got this:

List<Serializable> objs = holder.value.getContent();

The list is filled with 10 serialized objects.

How to deserialize them? Since ObjectInputStream expects an FileInputStream parameter and not an serialized object.

I am sure there must be a way to deserialize and object without a FileInputStream.

(The holder is a respons from a CodeUnit function from navision 2013)

2 Answers2

2

If they are really Serializable instances in that list, then you don't need to deserialize them. It would only be if they were a byte[] or InputStream, typically, that would mean they were still serialized.

So just cast them to what you expect them to be.

artbristol
  • 32,010
  • 5
  • 70
  • 103
0

It expects InputStream and it's not mandatory to use FileInputStream

InputStream is;
ObjectInputStream in;
Object obj;
in = new ObjectInputStream(is);
obj = in.readObject();
in.close();