(Java) Appending Strings to BinData
Demonstrates appending strings to a BinData..
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[])
{
CkBinData binData1 = new CkBinData();
// Append a string using a 1-byte per char encoding
binData1.AppendString("This is a test","windows-1252");
System.out.println(binData1.getEncoded("hex"));
// The bytes contained within the binData1 (in hex) are: 54,68,69,73,20,69, ...
CkBinData binData2 = new CkBinData();
// Append a string using a 2-byte per char encoding
binData2.AppendString("This is a test","utf-16");
System.out.println(binData2.getEncoded("hex"));
// The bytes contained within the binData2 (in hex) are: 54,00,68,00,69,00,73,00,20,00,69,00, ...
}
}
|