longblob存入html文件

  • 将html文件读取然后进行存储

InputStream input1 = new FileInputStream(“F:/456123.html”);
ByteArrayOutputStream output = new ByteArrayOutputStream();
int temp = 0;
while ((temp = input1.read()) != -1) {
output.write(temp);
}
String s = output.toString();

  • 将s进行存储,需要将其转成utf-8才可以

String remsgss = URLEncoder.encode(s, “utf-8”);

-读取数据

String content = new String(res.getBlob(“B_INPUT”).getBytes((long)1, (int)res.getBlob(“B_INPUT”).length()),“utf-8”);

-将读出的数据转换,因为我们存入的是utf-8,读出来需要解析

String strUTF8 = URLDecoder.decode(content, “utf-8”);

-ps:额外补充,因为html中含有需要转移的字符/,我们可以将/转变成*然后给前段传递

String s = strUTF8.replaceAll(“/”, “*”);

-如果不进行utf-8转换存储会发生如下错误
在这里插入图片描述

  • ps:补充 数据读取和写入代码
  • InputStream input1 = new FileInputStream("F:/456123.html");
      ByteArrayOutputStream output = new ByteArrayOutputStream();
      int temp = 0;
      while ((temp = input1.read()) != -1) {
          output.write(temp);
      }
      String s = output.toString();
    
      byte[] bytes = output.toByteArray();
      FileOutputStream fileOutputStream;
       fileOutputStream = new FileOutputStream("F:/xxxxx.html");
      fileOutputStream.write(bytes);
    
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值