Sample code for 30+ languages & platforms
JavaScript

bz2 Compress File

Compress a file to the bz2 file format.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

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

var bz2 = new CkBz2();

// Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
success = bz2.CompressFile("qa_data/hamlet.xml","qa_output/hamlet.bz2");
if (success !== true) {
    console.log(bz2.LastErrorText);
    return;
}

console.log("Success.");