-
-
Notifications
You must be signed in to change notification settings - Fork 3
zlib.ZStream.Open
Andrew Lambert edited this page Nov 26, 2022
·
22 revisions
Shared Function Open(InputStream As Readable, Encoding As Integer = zlib.Z_DETECT) As zlib.ZStream
Shared Function Open(InputStream As FolderItem, Encoding As Integer = zlib.Z_DETECT) As zlib.ZStream
Name | Type | Comment |
---|---|---|
InputStream | Readable, FolderItem | The file or stream to decompress from. |
Encoding | Integer | Optional. The type of compression. |
A new instance of ZStream.
Opens a compressed file or readable stream for decompression. On error an exception will be raised.
This example demonstrates how to use the ZStream.Open
and ZStream.Create
shared methods in concert with the built-in BinaryStream
class to read and write a gzip-compressed text file on the user's desktop.
Dim outfile As FolderItem = SpecialFolder.Desktop.Child("hello.txt.gz")
Dim filestream As BinaryStream
Dim gzipstream As zlib.ZStream
' Create the file and then the compression stream
filestream = BinaryStream.Create(outfile)
gzipstream = zlib.ZStream.Create(filestream, zlib.Z_DEFAULT_COMPRESSION, zlib.GZIP_ENCODING)
For i As Integer = 0 To 9
gzipstream.Write("This text will be compressed using gzip!")
Next
gzipstream.Close()
filestream.Close()
' Open the file and then the decompression stream
filestream = BinaryStream.Open(outfile)
gzipstream = zlib.ZStream.Open(filestream, zlib.GZIP_ENCODING)
Dim s As String
Do Until gzipstream.EOF
s = gzipstream.Read(1024 * 64)
Loop
gzipstream.Close()
filestream.Close()
MsgBox(s)
Wiki home | Project page | Bugs | Become a sponsor
Text and code examples are Copyright ©2014-24 Andrew Lambert, offered under the CC BY-SA 3.0 License.