Java SQL Blob getDataFromBlob(Blob b)

Here you can find the source of getDataFromBlob(Blob b)

Description

get Data From Blob

License

Open Source License

Parameter

Parameter Description
b a parameter

Exception

Parameter Description
SQLException an exception
IOException an exception
Exception an exception

Declaration

public static final byte[] getDataFromBlob(Blob b) throws SQLException, IOException 

Method Source Code

//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();
    }
}

Related

  1. blob2FloatArray(Blob blob)
  2. blobToBytes(Blob blob)
  3. blobToBytes(Blob blob)
  4. getAsString(Blob blob)
  5. getBlobType(byte[] image)
  6. getDataFromBlob(Blob b)
  7. getLongBlobTypeString(Connection conn)
  8. getString(Blob blob)
  9. getStringValue(Blob blob)