惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - hone

管理 java学习 服务器相关 总统和亿万富翁经典语录(转载) js学习笔记 最近学习计划 VC控制Excel 真乱(转自csdn) 沟通(网上搜集) 工作 无题 将文档发送到打印机(From MSN) 经典68个故事 Manually Invalidating All Stale Sessions 图形相关 在Oracle9i中计算时间差 六度分隔 经典故事 新年竟然第一篇?!
java的zip压缩(转自Jeet)
hone · 2005-03-22 · via 博客园 - hone

public static String compress(String s) throws IOException
        ByteArrayInputStream input 
= new ByteArrayInputStream(s.getBytes("UTF-8"));  
        ByteArrayOutputStream output 
= new ByteArrayOutputStream(1024); 
        GZIPOutputStream gzout 
= new GZIPOutputStream(output);  
 
        
byte[] buf=new byte[1024]; 
        
int number;  
 
         
        
while ((number = input.read(buf)) != -1){  
            gzout.write(buf,
0,number);  
        }
 
         
        gzout.close();  
        input.close(); 
         
        String result 
=new BASE64Encoder().encode(output.toByteArray()); 
         
        output.close(); 
         
        
return result; 
    }
 
     
    
public static String decompress(String data) throws IOException
        ByteArrayOutputStream output 
= new ByteArrayOutputStream(1024); 
        ByteArrayInputStream input 
= new ByteArrayInputStream(new BASE64Decoder().decodeBuffer(data));  
        GZIPInputStream gzinpt 
= new GZIPInputStream(input); 
        
byte[] buf = new byte[1024]; 
        
int number = 0
         
        
while((number = gzinpt.read(buf)) != -1)
            output.write(buf,
0,number); 
        }
 
          
        gzinpt.close(); 
        input.close(); 
         
        String result 
= new String(output.toString("UTF-8")); 
         
        output.close(); 
         
        
return result;  
         
    }