% Demonstrate how to
% - compress and decompress strings
% - use byte_stream to create a byte stream from String
% - use byte_stream to a String from byte streams
%   [NOTE that byte_stream works in either mode depending
%    on the first argument being a constant String]
% - use GZIPOutputStream to compress byte streams
% - use copy_stream to copy streams

:- eval(test038()).

test038() :-
	println(["==========test038=========="]),
	byte_stream("toto","UTF-8",BAIS),
	FO=java.io.FileOutputStream("toto.gz"),
	ZFO=java.util.zip.GZIPOutputStream(FO),
	copy_stream(BAIS,ZFO),
	println(["Compressed file created."]).
test038() :-
	FI=java.io.FileInputStream("toto.gz"),
	ZFI=java.util.zip.GZIPInputStream(FI),
	BAOS=java.io.ByteArrayOutputStream(),
	copy_stream(ZFI,BAOS),
	byte_stream(Result,"UTF-8",BAOS),
	println(["The original string read from the compressed file: ",Result]).
