[fpc-pascal] How to use TCompressionStream?
Felipe Monteiro de Carvalho
felipemonteiro.carvalho at gmail.com
Sat Jun 21 18:56:29 CEST 2008
Hello,
I am trying to use TCompressionStream to compress a string. But the
destination stream is empty. Here is by code, thanks:
program stringcompressor;
{$apptype console}
uses
Classes, SysUtils, zstream;
var
Compressor: TCompressionStream;
Source: TStringStream;
Dest: TMemoryStream;
i: Integer;
begin
Source := TStringStream.Create('The string to be compressed');
Dest := TMemoryStream.Create();
Compressor := TCompressionStream.Create(clDefault, Dest);
try
Compressor.CopyFrom(Source, Source.Size);
Write('The result is: ');
Dest.Position := 0;
for i := 0 to Dest.Size - 1 do
IntToHex(Dest.ReadByte, 2);
WriteLn('');
finally
Compressor.Free;
Dest.Free;
Source.Free;
end;
end.
More information about the fpc-pascal
mailing list