I need to make a Byte out of a ByteArrayOutPutStream, but this is not working. When I log the outcome of baos.toByteArray(); it only shows me eleven characters, no matter which file I try to upload, the log entry looks like this: [B@544641ab
This is the code:
[code]
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); // Stream to write to
upload = new Upload();
upload.setReceiver(new Upload.Receiver() {
@Override
public OutputStream receiveUpload(String filename, String mimeType) {
return baos; // Return the output stream to write to
}
});
upload.addSucceededListener(new Upload.SucceededListener() {
@Override
public void uploadSucceeded(Upload.SucceededEvent succeededEvent) {
System.out.println ( baos.toByteArray().toString());
}
});
[/code]Why is this not working and why is it giving me this strange 11 characters sized Array instead of the usual Byte-Array of the uploaded file?
Is there any better way to get to the byte-array of the uploaded file? I need to store the file in a database, and to do so I need the byte array of it.