Sample code for 30+ languages & platforms
React Native

bz2 Compress File

Compress a file to the bz2 file format.

Chilkat React Native Downloads

React Native
import { Bz2 } from '@chilkat/react-native'

async function chilkatExample() {
  // This example requires the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  const bz2 = new Bz2();

  // Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
  try {
    await bz2.compressFileAsync('qa_data/hamlet.xml', 'qa_output/hamlet.bz2');
  } catch {
    console.log(bz2.lastErrorText);
    return;
  }

  console.log('Success.');
}