标签:style blog class code java color
原文地址http://www.oschina.net/code/snippet_135225_5485#8747,仅仅第十一行代码,便可将BLOB类型转化为String类型,简单粗暴,我喜欢
1 String s1="1231dsdgasd的飒飒大"; 2 3 Clob c = new SerialClob(s1.toCharArray());//String 转 clob 4 Blob b = new SerialBlob(s1.getBytes("GBK"));//String 转 blob 5 // 也可以这样不传字符集名称,默认使用系统的 6 // Blob b = new SerialBlob(s1.getBytes()); 7 8 String clobString = c.getSubString(1, (int) c.length());//clob 转 String 9 String blobString = new String(b.getBytes(1, (int) b.length()),"GBK");//blob 转 String 10 // 前面若没传入字符集名称,则这里也不需要传入,以免出错 11 // String blobString = new String(b.getBytes(1, (int) b.length())); 12 13 System.out.println(clobString); 14 System.out.println(blobString);
CLOB/BOLB与String互转,布布扣,bubuko.com
标签:style blog class code java color
原文地址:http://www.cnblogs.com/sunlower-zyb/p/3715606.html