How can I read a java.sql.Clob into a byte[]?
with commons-io
byte[] data = IOUtils.toByteArray(clob.getAsciiStream());
int length = clob.getLength();
byte[] array = new byte[length];
InputStream in = clob.getAsciiStream();
int offset = 0;
int n;
do
n = in.read(array, offset, length - offset);
while (n != -1);
Try the above snippet of code for reading a clob into Byte array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With