解压缩的问题

java_fox 2004-09-08 07:27:02
哪位大虾给一段针对已经压缩的字符串解压缩的代码,谢过了,已经采用,百分相送
...全文
159 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
drift1981 2004-09-09
  • 打赏
  • 举报
回复
到网上搜索abbrevia,这是一套文件压缩和解压的组件,可能达不到你的要求
子秦1117 2004-09-09
  • 打赏
  • 举报
回复
abbrevia的组件在什么地方,找不到。
drift1981 2004-09-09
  • 打赏
  • 举报
回复
不好意思,把问题看错了,当我没回过!
java_fox 2004-09-09
  • 打赏
  • 举报
回复
我的意思是不通过文件中转,直接解压缩已经被压缩过的字符串,有没有办法?
drift1981 2004-09-09
  • 打赏
  • 举报
回复
abbrevia的组件
压缩: txtname :='c:\1.txt';
Fzipname :='c:\1.zip';
if FileExists(txtname) then
begin
Fzip.FileName :=Fzipname;
Fzip.AddFiles(txtname, 0);
Fzip.CloseArchive;
end
else begin
application.messagebox(pchar('无法压缩,请检查是否有'+txtname+'这个文件!'),'警告',MB_OK+MB_ICONWARNING);
exit;
end;
解压:
Funzip.BaseDirectory :=ExtractFilePath(Application.Exename);
Funzip.FileName :='c:\1.zip';
Funzip.ExtractFiles('*.*');
java_fox 2004-09-09
  • 打赏
  • 举报
回复
哪位老兄能给我详细解释一下这个方法怎么用,实在是对delphi不熟,主要是对指针等概念不熟,目的:将一个压缩过的字符串解压缩并返回一个新的字符串,
zlib.DeCompressBuf(const InBufer: pointer; InBytes: integer;
outEstimat: integer;
out OutBuffer: Pointer; OutBytes: Integer);

附送java里面的实现:
public class ByteUtils {
public static byte[] compressBytes(byte[] bytes) throws IOException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(new GZIPOutputStream(baos));
dos.write(bytes);
dos.close();
return baos.toByteArray();
}

public static byte[] decompressBytes(byte[] bytes)
throws IOException
{
GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(
bytes));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int len = -1;

while ((len = gis.read(buf)) >= 0)
{
baos.write(buf, 0, len);
}

gis.close();
baos.close();
return baos.toByteArray();
}
}
southdream 2004-09-08
  • 打赏
  • 举报
回复
用自带的那个吧

zlib.CompressBuf(const InBufer: pointer; InBytes: integer;
out OutBuffer: Pointer; OutBytes: Integer);
zlib.DeCompressBuf(const InBufer: pointer; InBytes: integer;
outEstimat: integer;
out OutBuffer: Pointer; OutBytes: Integer);

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧