Code example for Blob

Methods: getBinaryStream

0
        if (val == null) return null;
 
        if (val instanceof Blob) {
            Blob b = (Blob)val;
            try { 
                return IOUtils.toByteArray( b.getBinaryStream() );
            } catch (SQLException e) {
                throw new ConverterException("Error converting Blob to byte[]", e);
            } catch (IOException e) {
                throw new ConverterException("Error converting Blob to byte[]", e);
            } 
        } 
 
        if (val instanceof byte[]){
            return (byte[])val;
        } 
 
        throw new RuntimeException("could not convert " + val.getClass().getName() + " to byte[]");
    } 
}