(Java) StringBuilder GetEncoded
Demonstrates the Chilkat StringBuilder GetEncoded method.
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[])
{
String s = "The quick brown fox jumps over the lazy dog";
CkStringBuilder sb = new CkStringBuilder();
sb.Append(s);
// output: The quick brown fox jumps over the lazy dog
System.out.println(sb.getAsString());
// Get the string encoded to base64, without changing the contents of sb.
// output: VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==
System.out.println(sb.getEncoded("base64","utf-8"));
// The contents of sb are not changed..
// output: The quick brown fox jumps over the lazy dog
System.out.println(sb.getAsString());
}
}
|