import com.util.IArchive;
import java.io.*; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; import org.apache.log4j.Category; import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; public class CompressImp implements IArchive { private static Category log4j = Category.getInstance("Commonlog"); private Category logError; public CompressImp() { logError = Category.getInstance("CommonlogError"); } public String compress(String sourceData) { String msg; msg = "ERROR"; ByteArrayOutputStream baOS = null; GZIPOutputStream zipOS = null; try { baOS = new ByteArrayOutputStream(); zipOS = new GZIPOutputStream(baOS); byte msgBt[] = sourceData.getBytes("UTF-8"); zipOS.write(msgBt); zipOS.close(); byte zipBt[] = baOS.toByteArray(); BASE64Encoder encoder = new BASE64Encoder(); msg = encoder.encode(zipBt); } catch (Exception e) { e.printStackTrace(); logError.error("压缩异常" + e.getMessage()); } finally { try { baOS.close(); zipOS.close(); } catch (IOException ex) { ex.printStackTrace(); } } return msg; } public String decompress(String sourceData) { String dest; byte msgBt[] = new byte[51200]; dest = "ERROR"; ByteArrayInputStream baIS = null; GZIPInputStream zipIS = null; BufferedInputStream bIS = null; try { BASE64Decoder decoder = new BASE64Decoder(); byte zipBt[] = decoder.decodeBuffer(sourceData); baIS = new ByteArrayInputStream(zipBt); zipIS = new GZIPInputStream(baIS); bIS = new BufferedInputStream(zipIS); bIS.read(msgBt); dest = new String(msgBt, "UTF-8"); dest = dest.trim(); } catch (Exception e) { e.printStackTrace(); logError.error("压缩异常" + e.getMessage()); } finally { try { baIS.close(); zipIS.close(); bIS.close(); } catch (IOException ex) { ex.printStackTrace(); } } return dest; } } |
个人日记(88)
java(32)
电脑维护(19)
名人名言(13)
影音数码(10)
java脚本(9)
数据库(7)
电脑知识(6)
空间技巧(6)
九型人格(6)
游戏动漫(4)
笑死不管(3)
C++(3)
我的图志(3)
java ee(3)
情感心思(3)
空间应用(2)
T__Y(2)
情感天地(2)
通信知识(1)
故事连载(1)
闲聊天地(1)
枫叶原創(1)
杀毒软件(1)
桂宝四格(1)
娱乐八卦(1)
我的商品(1)
腾讯十周年(1)
J2EE(1)
死能无憾(1)
个人收藏(1)
转载空间(1)
测试(1)
偶的日记(1)
共同分享(1)
风筝教程(1)
球迷约会战术指南
暴笑!上班听音乐,下班看a片!!! 你有男朋友吗?你有女朋友吗? 黑帮老大儿子的请假条 [归纳]武侠片终级定律! 幽默短信大观(7) 幽默短信大观(6) 幽默短信大观(3) 这样的老婆 真舒服! 只收评论 密闻:光绪的妃子们雷人照片 [好马] 太神奇了.能看穿你的心的游戏(吉普赛人古老读心术) 朋友来弹首歌吧! 一个学期的表情变化,看看你读书的时候是不是这样? 寒江独钓趣闻 公务员面试白话考试试题,不看会后悔! 三字经 加菲语录 经典搞笑文章 人才啊``
<script type="text/javascript"><!-- google_ad_client = "pub-5023259701394994"; /* 300x250, 创建于 09-8-15 */ google_ad_slot = "4928071629"; google_ad_width = 300; google_ad_height = 250; //--> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script> <script>google_protectAndRun("ads_core.google_render_ad", google_handleError, google_render_ad);</script>
|
<script> function getta(ww){ var e=document.getElementById(ww); var t=e.offsetTop; var l=e.offsetLeft; while(e=e.offsetParent){ t+=e.offsetTop; l+=e.offsetLeft; } return{x:l, y:t}; } function pb(){ var pos=getta("shubiao_"),newx=(pos.x)+60,newy=(pos.y)-60;//高度往上 document.getElementById("pingbi").style.cssText='display:block;left:'+ newx +'px;top:'+ newy +'px;position:absolute;width:310px;z-index:1000;';} function qx_pb(){document.getElementById("pingbi").style.display='none'} //控制图片最大 var w=document.images; var ws=w.length; if (ws>1){ for (var i=0;i<ws;i++) { offset_width = w[i].offsetWidth; if(offset_width>660){ w[i].width = 660; } } } </script>