首页 > 学院 > 开发设计 > 正文

数据库Blob数据类型转String

2019-11-14 15:06:12
字体:
来源:转载
供稿:网友

blob数据是存储大对象数据类型, 一般存放二进制的,所以才用字节存取。

首先判断blob数据是否为空,然后采用输入流读出数据,具体代码如下:

 

 1 String content = null;  2   try { 3  4    if(image != null){ 5     InputStream is = image.getBinaryStream(); 6     byte[] b = new byte[is.available()]; 7     is.read(b, 0, b.length); 8     content = new String(b);  9    }10   System.out.PRintln(content);11   } catch ( IOException e) {12    e.printStackTrace();13   }

 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表