哪位大虾给一段针对已经压缩的字符串解压缩的代码,谢过了,已经采用,百分相送

解决方案 »

  1.   

    用自带的那个吧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);
      

  2.   

    哪位老兄能给我详细解释一下这个方法怎么用,实在是对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();
        }
    }
      

  3.   

    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('*.*');
      

  4.   

    abbrevia的组件在什么地方,找不到。
      

  5.   

    到网上搜索abbrevia,这是一套文件压缩和解压的组件,可能达不到你的要求