Here you can find the source of getDataFromBlob(Blob b)
Parameter | Description |
---|---|
b | a parameter |
Parameter | Description |
---|---|
SQLException | an exception |
IOException | an exception |
Exception | an exception |
public static final byte[] getDataFromBlob(Blob b) throws SQLException, IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.sql.Blob; import java.sql.SQLException; public class Main { /**//from w ww. j a v a2 s . c o m * * @param b * @return * @throws SQLException * @throws IOException * @throws Exception */ public static final byte[] getDataFromBlob(Blob b) throws SQLException, IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); InputStream in = b.getBinaryStream(); byte[] buffer = new byte[10240]; int len = 0; while ((len = in.read(buffer, 0, 10240)) != -1) { bout.write(buffer, 0, len); } return bout.toByteArray(); } }