This question already has an answer here:
- What's the simplest way to print a Java array? 32 answers
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?