当前位置: 首页 > news >正文

企业门户网站建设方案书万能搜索引擎入口

企业门户网站建设方案书,万能搜索引擎入口,无锡网站排名优化公司哪家好,商城app官方下载应用场景 当字符串太长#xff0c; 需要将字符串值存入数据库时#xff0c;如果字段长度不够#xff0c;则会出现插入失败#xff1b; 或者需要进行Http传输时#xff0c;由于参数长度过长造成http传输失败等。 字符串压缩与解压方法 方法一#xff1a;用 Java8中的…应用场景 当字符串太长 需要将字符串值存入数据库时如果字段长度不够则会出现插入失败 或者需要进行Http传输时由于参数长度过长造成http传输失败等。 字符串压缩与解压方法 方法一用 Java8中的gzip /*** 使用gzip压缩字符串* param str 要压缩的字符串* return*/ public static String compress(String str) {if (str null || str.length() 0) {return str;}ByteArrayOutputStream out new ByteArrayOutputStream();GZIPOutputStream gzip null;try {gzip new GZIPOutputStream(out);gzip.write(str.getBytes());} catch (IOException e) {e.printStackTrace();} finally {if (gzip ! null) {try {gzip.close();} catch (IOException e) {e.printStackTrace();}//加入Java开发交流君样756584822一起吹水聊天}}return new sun.misc.BASE64Encoder().encode(out.toByteArray()); }/*** 使用gzip解压缩* param compressedStr 压缩字符串* return*/ public static String uncompress(String compressedStr) {if (compressedStr null) {return null;}ByteArrayOutputStream out new ByteArrayOutputStream();ByteArrayInputStream in null;GZIPInputStream ginzip null;byte[] compressed null;String decompressed null;try {compressed new sun.misc.BASE64Decoder().decodeBuffer(compressedStr);in new ByteArrayInputStream(compressed);ginzip new GZIPInputStream(in);byte[] buffer new byte[1024];int offset -1;while ((offset ginzip.read(buffer)) ! -1) {out.write(buffer, 0, offset);}decompressed out.toString();} catch (IOException e) {e.printStackTrace();} finally {if (ginzip ! null) {try {ginzip.close();} catch (IOException e) {}//加入Java开发交流君样756584822一起吹水聊天}if (in ! null) {try {in.close();} catch (IOException e) {}}if (out ! null) {try {out.close();} catch (IOException e) {}}}return decompressed; }方法二用org.apache.commons.codec.binary.Base64 /*** 使用org.apache.commons.codec.binary.Base64压缩字符串* param str 要压缩的字符串* return*/ public static String compress(String str) {if (str null || str.length() 0) {return str;}//加入Java开发交流君样756584822一起吹水聊天return Base64.encodeBase64String(str.getBytes()); }/*** 使用org.apache.commons.codec.binary.Base64解压缩* param compressedStr 压缩字符串* return*/ public static String uncompress(String compressedStr) {if (compressedStr null) {return null;}return Base64.decodeBase64(compressedStr); }注意事项 在web项目中服务器端将加密后的字符串返回给前端前端再通过ajax请求将加密字符串发送给服务器端处理的时候在http传输过程中会改变加密字符串的内容导致服务器解压压缩字符串发生异常 java.util.zip.ZipException: Not in GZIP format 解决方法 在字符串压缩之后将压缩后的字符串BASE64加密在使用的时候先BASE64解密再解压即可。
http://wiki.neutronadmin.com/news/93530/

相关文章:

  • 基于php的电子商城网站建设俄罗斯搜索引擎yandex推广入口
  • 如何建论坛网站网站的功能模块
  • 网站建设w亿玛酷1流量订制怎么设计个人logo
  • 昆明网站seo技术厂家微信小程序wordpress
  • 网站如何做微信支付宝支付宝支付宝海口建设网站的公司哪家好
  • 网络营销的主要内容有哪些seo网站建设公司
  • 企业网站源码aspnet网站开发作业
  • 哪家网站建设公司好谷歌浏览器下载视频
  • 衡水市网站建设搭建网站平台有前途吗
  • 网站备案流程图片七牛云配置wordpress
  • 合肥网站制作哪家有名怎样网站不用备案
  • 设计师兼职网站安阳企业网站建设
  • 霞山手机网站建设公司怎么做企业网站排名
  • 小说下载网站哪个好网站空间永久免费
  • 手机可以做3d动漫视频网站建设环评备案登记网站
  • 手机如何制作网站源码wordpress v4.1教程
  • 重庆建设工程交易中心网站徐州企业制作网站
  • 天津做宠物饲料的网站编程学习入门网站
  • 门户网站 方案莱州网络推广
  • 家具技术支持东莞网站建设上海做网站品牌公司有哪些
  • 赣州建设网站公司大朗镇网站仿做
  • 天创网站网站建设促销活动
  • 佛山网站建设咨询大连手机自适应网站建设公司
  • 建站总结报告长沙 外贸网站建设公司价格
  • 国外优秀论文网站网页设计公司网站
  • 金融行业网站建设公司网站建设流程包括哪些内容
  • 响应式网站 尺寸如何做企业黄页网站
  • 制作门户网站网站开发的意义和作用
  • 东莞网站seo公司哪家大十大没用的证书
  • 网站建设zrhskj搜索引擎优化技术都有哪些