Sample code for 30+ languages & platforms
Dart

bz2 Compress File

Compress a file to the bz2 file format.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

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

  final bz2 = CkBz2();

  // Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
  try {
    bz2.compressFile('qa_data/hamlet.xml', 'qa_output/hamlet.bz2');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  print('Success.');
}