DBUnitのテストデータで、ROW型のデータを記述するときに使用。(なんでbase64なんだ?)
import org.dbunit.util.Base64;public class Base64Encoder {
public static void main(String args) {
if (args.length == 1) {
byte src = asByteArray(args[0]);
String encoded = Base64.encodeBytes(src);
System.out.println(encoded);
} else {
System.out.println("Usage: Base64Encoder {hexstring}");
}}
private static byte asByteArray(String hex) {
byte bytes = new byte[hex.length() / 2];for (int index = 0; index < bytes.length; index++) {
bytes[index] =
(byte) Integer.parseInt(
hex.substring(index * 2, (index + 1) * 2),
16);
}return bytes;
}}