Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

ByteArrayOutPutSteam to Byte[] not working properly with Upload-Component

Tobias Kuess
6 years ago Oct 11, 2016 10:51am
Marco Collovati
6 years ago Oct 11, 2016 11:20am

What you are printing ([B@544641ab) is not the content of the byte array but the string representation of a byte array object ([ indicates it is an array, B is for byte and the number is the hashcode, see Object.toString and Class.getName javadocs for further info).
If you want to print the string representation of the contents of the array you can use Arrays.toString(...).

BTW using baos.toByteArray() should be correct to store the file in the db blob field.


Tobias Kuess
6 years ago Oct 11, 2016 1:22pm