@Override public String toString() { return "[0x" + DatatypeConverter.printHexBinary(key) + "]"; } }
@Override public String toString() { return DatatypeConverter.printHexBinary(hash); } }
public String marshal(byte[] bytes) { if(bytes==null) return null; return DatatypeConverter.printHexBinary(bytes); } }
@Override public String encodeKey(byte[] key) { return DatatypeConverter.printHexBinary(key); } }
byte bytes[] = {(byte)0, (byte)0, (byte)134, (byte)0, (byte)61}; System.out.println(javax.xml.bind.DatatypeConverter.printHexBinary(bytes));
/** * Turns an array of bytes into a String representing each byte as an * unsigned hex number. * * @param bytes an array of bytes to convert to a hex-string * @return generated hex string */ public static String encodeHex(byte[] bytes) { return DatatypeConverter.printHexBinary(bytes).toLowerCase(); }
/** * Converts a byte array to a lower case hex representation. * If the given byte array is <tt>null</tt>, an empty string is returned. */ public static String toHex(byte[] bytes) { if (bytes == null) { return ""; } else { return DatatypeConverter.printHexBinary(bytes).toLowerCase(); } }
import javax.xml.bind.DatatypeConverter; public static String toHexString(byte[] array) { return DatatypeConverter.printHexBinary(array); } public static byte[] toByteArray(String s) { return DatatypeConverter.parseHexBinary(s); }
@Override public void run() { final String hex = DatatypeConverter.printHexBinary(bytes); // avoid optimization by HotSpot if (hex.length() != bytes.length * 2) { throw new RuntimeException(); } }
import javax.xml.bind.DatatypeConverter; public static String toHexString(byte[] array) { return DatatypeConverter.printHexBinary(array); } public static byte[] toByteArray(String s) { return DatatypeConverter.parseHexBinary(s); }
public static String calMD5Checksum(String filename) { byte[] b; b = createChecksum(filename); String digestInHex = DatatypeConverter.printHexBinary(b).toUpperCase(); return digestInHex; } }
public static String calMD5Checksum(String filename) { byte[] b; b = createChecksum(filename); String digestInHex = DatatypeConverter.printHexBinary(b).toUpperCase(); return digestInHex; } }
private static String encodeKafkaKey(final byte[] key, final String encoding) { if (key == null) { return null; } if (HEX_ENCODING.getValue().equals(encoding)) { return DatatypeConverter.printHexBinary(key); } else if (UTF8_ENCODING.getValue().equals(encoding)) { return new String(key, StandardCharsets.UTF_8); } else { return null; // won't happen because it is guaranteed by the Allowable Values } }
private static String encodeKafkaKey(final byte[] key, final String encoding) { if (key == null) { return null; } if (HEX_ENCODING.getValue().equals(encoding)) { return DatatypeConverter.printHexBinary(key); } else if (UTF8_ENCODING.getValue().equals(encoding)) { return new String(key, StandardCharsets.UTF_8); } else { return null; // won't happen because it is guaranteed by the Allowable Values } }
private static String encodeKafkaKey(final byte[] key, final String encoding) { if (key == null) { return null; } if (HEX_ENCODING.getValue().equals(encoding)) { return DatatypeConverter.printHexBinary(key); } else if (UTF8_ENCODING.getValue().equals(encoding)) { return new String(key, StandardCharsets.UTF_8); } else { return null; // won't happen because it is guaranteed by the Allowable Values } }
public DatagramPacket sendCmdPkt(int timeout, CmdPayload aCmd) { log.info("sendCmdPkt called with " + DatatypeConverter.printHexBinary(aCmd.getPayload().getData())); return null; } }
@Test public void shouldConvertMySqlBytesToLine() throws Exception { byte[] mysqlBytes = DatatypeConverter.parseHexBinary("E6100000010200000002000000E3A59BC420F01B4015A143A69D38324000000000000000000000000000000000"); //This represents 'SRID=4326;LINESTRING(6.9845 18.22115554, 0 0)' MySqlGeometry geom = MySqlGeometry.fromBytes(mysqlBytes); assertFalse(geom.isPoint()); assertEquals(Integer.valueOf(4326), geom.getSrid()); assertEquals("010200000002000000E3A59BC420F01B4015A143A69D38324000000000000000000000000000000000", DatatypeConverter.printHexBinary(geom.getWkb())); }
@Test public void shouldConvertMySqlBytesToPolygon() throws Exception { byte[] mysqlBytes = DatatypeConverter.parseHexBinary("E61000000103000000010000000400000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F000000000000000000000000000000000000000000000000"); //This represents 'SRID=4326;POLYGON((0 0, 1 1, 1 0, 0 0))' MySqlGeometry geom = MySqlGeometry.fromBytes(mysqlBytes); assertFalse(geom.isPoint()); assertEquals(geom.getSrid(), Integer.valueOf(4326)); assertEquals("0103000000010000000400000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F000000000000000000000000000000000000000000000000", DatatypeConverter.printHexBinary(geom.getWkb())); }
@Test public void shouldConvertMySqlBytesToGeomCollection() throws Exception { byte[] mysqlBytes = DatatypeConverter.parseHexBinary("730C00000107000000020000000101000000000000000000F03F000000000000F03F01020000000200000000000000000000000000000000000000000000000000F03F000000000000F03F"); //This represents 'SRID=3187;GEOMETRYCOLLECTION(POINT(1 1), LINESTRING(0 0, 1 1))' MySqlGeometry geom = MySqlGeometry.fromBytes(mysqlBytes); assertFalse(geom.isPoint()); assertEquals(geom.getSrid(), Integer.valueOf(3187)); assertEquals("0107000000020000000101000000000000000000F03F000000000000F03F01020000000200000000000000000000000000000000000000000000000000F03F000000000000F03F", DatatypeConverter.printHexBinary(geom.getWkb())); }
@Test public void shouldConvertMySqlBytesToMultiGeometry() throws Exception { byte[] mysqlBytes = DatatypeConverter.parseHexBinary("000000000104000000020000000101000000000000000000F03F000000000000F03F010100000000000000000000400000000000000040"); //This represents 'MULTIPOINT(1 1, 2 2)'' MySqlGeometry geom = MySqlGeometry.fromBytes(mysqlBytes); assertFalse(geom.isPoint()); assertEquals(geom.getSrid(), null); assertEquals("0104000000020000000101000000000000000000F03F000000000000F03F010100000000000000000000400000000000000040", DatatypeConverter.printHexBinary(geom.getWkb())); } }