Skip to content

BZip2.BZ2Stream.Constructor

Andrew Lambert edited this page Nov 27, 2022 · 3 revisions

BZip2.BZ2Stream.Constructor

Method Signatures

 Sub Constructor(Source As MemoryBlock,  CompressionLevel As Integer = BZip2.Z_DEFAULT_COMPRESSION)
 Sub Constructor(Source As BinaryStream, CompressionLevel As Integer = BZip2.Z_DEFAULT_COMPRESSION)

Parameters

Name Type Comment
Source MemoryBlock, BinaryStream A zero-length MemoryBlock or BinaryStream to use for output, or a >0 length MemoryBlock or BinaryStream to use for input
CompressionLevel Integer Optional. The compression level for the output. Valid levels are 1(fast) to 9(best)

Remarks

Constructs a BZ2Stream from the Source MemoryBlock or BinaryStream. If the Source as a MemoryBlock has a Size of zero, or as a BinaryStream its Length is equal to its Position, then compressed data will be written to the Source; otherwise, the Source will be used as input to be decompressed.

Example

This example creates a BZ2Stream from a zero-length MemoryBlock and writes(compresses) as string into it, then it creates a second BZ2Stream for reading the compressed string:

  Dim data As New MemoryBlock(0)
  Dim z As New BZip2.BZ2Stream(data)
  z.Write("Hello, world!")
  z.Close
  z = New BZip2.BZ2Stream(data)
  MsgBox(z.Read(64))
Clone this wiki locally