Java
Chilkat2 Java
bz2 Compress File
Compress a file to the bz2 file format.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.Bz2;
import com.chilkatsoft.chilkat2.ChilkatException;
public class ChilkatExample {
public static void main(String[] args) {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Bz2 bz2 = new Bz2();
// Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
try {
bz2.compressFile("qa_data/hamlet.xml", "qa_output/hamlet.bz2");
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
System.out.println("Success.");
}
}