Thursday, 7 September 2017

java - Cannot see the contents of the array printed in console

public RMI post(PrintStream stream, Object object)
{
try
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();

ObjectOutputStream oos = new ObjectOutputStream(baos);

//


oos.writeObject(System.rmi);

oos.flush();

oos.close();

//

stream.println("Class size: " + baos.toByteArray().length);


stream.println("Class data: " + baos.toByteArray());

stream.flush();

stream.close();

//
}
catch (Exception e)
{

e.printStackTrace();
}

return this;


}



This prints [B@12843fce instead of the expected underlying bytecode structure. The same operation works find with FileOutputStream but here not with ByteArrayOutputStream. We would really need this to work. Can you spot what's wrong or what's happened?

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...