@Test public void testStringToHexArray() { String hex = "019f314a"; byte[] hexArray = StringUtils.hexStringToByte(hex); byte[] expectedArray = new byte[]{1, -97, 49, 74 }; assertArrayEquals(expectedArray, hexArray); }
public static byte[] hexStringToByte(final String hex) { final byte[] bts = new byte[hex.length() / 2]; for (int i = 0; i < bts.length; i++) { bts[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16); } return bts; }
StringUtils { public static byte[] hexStringToByte(final String hex) { final byte[] bts = new byte[hex.length() / 2]; for (int i = 0; i < bts.length; i++) { bts[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16); } return bts; } }
StringUtils { public static byte[] hexStringToByte(final String hex) { final byte[] bts = new byte[hex.length() / 2]; for (int i = 0; i < bts.length; i++) { bts[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16); } return bts; } private  StringUtils(); }
StringUtils { public static byte[] hexStringToByte(final String hex) { final byte[] bts = new byte[hex.length() / 2]; for (int i = 0; i < bts.length; i++) { bts[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16); } return bts; } private  StringUtils(); static String byteToHexString(final byte[] bytes, final int start, final int end); static String byteToHexString(final byte[] bytes); static byte[] hexStringToByte(final String hex); static String arrayAwareToString(Object o); static String arrayToString(Object array); static String showControlCharacters(String str); static String getRandomString(Random rnd, int minLength, int maxLength); static String getRandomString(Random rnd, int minLength, int maxLength, char minValue, char maxValue); static String generateRandomAlphanumericString(Random rnd, int length); static void writeString(@Nonnull String str, DataOutputView out); static String readString(DataInputView in); static void writeNullableString(@Nullable String str, DataOutputView out); static @Nullable String readNullableString(DataInputView in); static boolean isNullOrWhitespaceOnly(String str); @Nullable static String concatenateWithAnd(@Nullable String s1, @Nullable String s2); static String toQuotedListString(Object[] values); }
StringUtils { public static byte[] hexStringToByte(final String hex) { final byte[] bts = new byte[hex.length() / 2]; for (int i = 0; i < bts.length; i++) { bts[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16); } return bts; } private  StringUtils(); static String byteToHexString(final byte[] bytes, final int start, final int end); static String byteToHexString(final byte[] bytes); static byte[] hexStringToByte(final String hex); static String arrayAwareToString(Object o); static String arrayToString(Object array); static String showControlCharacters(String str); static String getRandomString(Random rnd, int minLength, int maxLength); static String getRandomString(Random rnd, int minLength, int maxLength, char minValue, char maxValue); static String generateRandomAlphanumericString(Random rnd, int length); static void writeString(@Nonnull String str, DataOutputView out); static String readString(DataInputView in); static void writeNullableString(@Nullable String str, DataOutputView out); static @Nullable String readNullableString(DataInputView in); static boolean isNullOrWhitespaceOnly(String str); @Nullable static String concatenateWithAnd(@Nullable String s1, @Nullable String s2); static String toQuotedListString(Object[] values);  }