(Java) Load Entire File into BinData
Demonstrates how to load an entire file into a BinData object.
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
CkFileAccess fac = new CkFileAccess();
boolean success = fac.OpenForRead("qa_data/pdf/sample.pdf");
if (success == false) {
System.out.println(fac.lastErrorText());
return;
}
CkBinData bd = new CkBinData();
int maxBytesToRead = 99999999;
success = fac.FileReadBd(maxBytesToRead,bd);
if (success == false) {
System.out.println(fac.lastErrorText());
return;
}
fac.FileClose();
// The bd object contains the file data...
success = bd.WriteFile("qa_output/sample.pdf");
}
}
|