java生成unix.z压缩_java解压缩.Z文件 Uncompress a unix compressed file--.Z

这是一个Java类,用于解压缩使用Unix 'compress'工具压缩的数据。代码基于gzip-1.2.4中的'unlzw.c'和原始'compress'代码。类通过读取输入流并进行LZW解码来实现解压缩功能。
摘要由CSDN通过智能技术生成

/*

* @(#)UncompressInputStream.java0.3-2 18/06/1999

*

* This file is part of the HTTPClient package

* Copyright (C) 1996-1999 Ronald Tschalr

*

* This library is free software; you can redistribute it and/or

* modify it under the terms of the GNU Lesser General Public

* License as published by the Free Software Foundation; either

* version 2 of the License, or (at your option) any later version.

*

* This library is distributed in the hope that it will be useful,

* but WITHOUT ANY WARRANTY; without even the implied warranty of

* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

* Lesser General Public License for more details.

*

* You should have received a copy of the GNU Lesser General Public

* License along with this library; if not, write to the Free

* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,

* MA 02111-1307, USA

*

* For questions, suggestions, bug-reports, enhancement-requests etc.

* I may be contacted at:

*

* ronald@innovation.ch

*

*/

package HTTPClient;

import java.io.IOException;

import java.io.EOFException;

import java.io.InputStream;

import java.io.FileInputStream;

import java.io.FilterInputStream;

/**

* This class decompresses an input stream containing data compressed with

* the unix "compress" utility (LZC, a LZW variant). This code is based

* heavily on the unlzw.c code in gzip-1.2.4 (written

* by Peter Jannesen) and the original compress code.

*

* @version0.3-2 18/06/1999

* @authorRonald Tschalr

*/

class UncompressInputStream extends FilterInputStream

{

/**

* @param is the input stream to decompress

* @exception IOException if the header is malformed

*/

public UncompressInputStream(InputStream is) throws IOException

{

super(is);

parse_header();

}

byte[] one = new byte[1];

public synchronized int read() throws IOException

{

int b = in.read(one, 0, 1);

if (b == 1)

return (one[0] & 0xff);

else

return -1;

}

// string table stuff

private static final int TBL_CLEAR = 0x100;

private static final int TBL_FIRST = TBL_CLEAR + 1;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值