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

Declaration

public static byte[] getDataFromBlob(Blob b) throws Exception 

Method Source Code


//package com.java2s;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.sql.Blob;

public class Main {
    public static byte[] getDataFromBlob(Blob b) throws Exception {
        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);/*from w  w  w .j av a  2  s  .  c om*/
        }
        bout.flush();
        return bout.toByteArray();
    }
}

Related

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