Sample code for 30+ languages & platforms
Lua

bz2 Compress File

Compress a file to the bz2 file format.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.

local bz2 = chilkat.Bz2.new()

-- Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
local success = bz2:compress_file("qa_data/hamlet.xml", "qa_output/hamlet.bz2")
if not success then
    print(bz2.last_error_text)
    return
end

print("Success.")