Sample code for 30+ languages & platforms
Swift

bz2 Compress File

Compress a file to the bz2 file format.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

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

    let bz2 = CkoBz2()!

    // Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
    success = bz2.compressFile(inPath: "qa_data/hamlet.xml", toPath: "qa_output/hamlet.bz2")
    if success != true {
        print("\(bz2.lastErrorText!)")
        return
    }

    print("Success.")

}