Oct 01

Read the bytes from the Blob into a ByteArrayOutputStream.


ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];

InputStream in = blob.getBinaryStream();

int n = 0;
while ((n=in.read(buf))>=0)
{
   baos.write(buf, 0, n);

}

in.close();
byte[] bytes = baos.toByteArray(); 

written by objects \\ tags: , , ,

Oct 01

Read the bytes from the blob using a ByteArrayOutputStream and then create a String from the resulting byte array.


ByteArrayOutputStream baos = new ByteAttayOutputStream();
byte[] buf = new byte[1024];

InputStream in = blob.getBinaryStream();

int n = 0;
while ((n=in.read(buf))>=0)
{
   baos.write(buf, 0, n);
}

in.close();
byte[] bytes = baos.toByteArray();
String blobString = new String(bytes); 

written by objects \\ tags: , ,