Java
Chilkat2 Java
Load Entire File into BinData
Demonstrates how to load an entire file into a BinData object.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.BinData;
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.FileAccess;
public class ChilkatExample {
public static void main(String[] args) {
FileAccess fac = new FileAccess();
try {
fac.openForRead("qa_data/pdf/sample.pdf");
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
BinData bd = new BinData();
int maxBytesToRead = 99999999;
try {
fac.fileReadBd(maxBytesToRead, bd);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
fac.fileClose();
// The bd object contains the file data...
bd.writeFile("qa_output/sample.pdf");
}
}