I'm trying to convert an image to an array of bytes in java to save it in a database, I used several methods to perform the conversion, and you could say that if it does, but it always returns a small part, this one of the codes that I have occupied:
public byte[] extractBytes(File imgPath) throws IOException {
BufferedImage bufferedImage = ImageIO.read(imgPath);
RecortaFotografia recorte = new RecortaFotografia(bufferedImage, 100, 100);
WritableRaster raster = bufferedImage.getRaster();
DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
return (data.getData());
}
But the result is always something similar to this:
[B@172675af
I have used other methods for conversion and the result is always the same. I do not find my mistake, or what I'm doing wrong. Why do you always return only part of me? or how can I get the entire string of the byte array?