1、Blob-->String

            String result = "";
            if (blob != null) {
                InputStream is = blob.getBinaryStream();
                ByteArrayInputStream bais = (ByteArrayInputStream) is;
                byte[] byte_data = new byte[bais.available()]; // bais.available()返回此输入流的字节数

                bais.read(byte_data, 0, byte_data.length);// 将输入流中的内容读到指定的数组
                BASE64Encoder encoder = new sun.misc.BASE64Encoder();          
                result = encoder.encodeBuffer(byte_data).trim();
                is.close();
            }

 

2、String-->Blob

          Blob blob = null;
  BASE64Decoder decoder = new sun.misc.BASE64Decoder();   
byte[] bytes1 = decoder.decodeBuffer(base64String);   ByteArrayInputStream bais = new ByteArrayInputStream(bytes1);   blob = Hibernate.createBlob(bais);

 

相关文章:

  • 2021-12-08
  • 2022-12-23
  • 2021-10-12
  • 2021-06-30
  • 2022-12-23
  • 2021-12-14
猜你喜欢
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
  • 2021-10-07
相关资源
相似解决方案