[fpc-pascal] How to use TCompressionStream?
Joao Morais
post at joaomorais.com.br
Sat Jun 21 19:08:53 CEST 2008
Felipe Monteiro de Carvalho wrote:
> 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);
What about use Compressor intead of Dest?
Joao Morais
> WriteLn('');
> finally
> Compressor.Free;
> Dest.Free;
> Source.Free;
> end;
> end.
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list