List of usage examples for java.lang Character digit
public static int digit(int codePoint, int radix)
From source file:Main.java
private static byte[] hexStringToByteArray(final String s) { final int len = s.length(); final byte[] data = new byte[len / 2]; for (int i = 0; i < len; i += 2) { data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16)); }/* www .ja v a 2 s .c o m*/ return data; }
From source file:Main.java
public static byte[] hexStringToByteArray(String hexString) { int len = hexString.length(); byte[] array = new byte[len / 2]; for (int i = 0; i < len; i += 2) { array[i / 2] = (byte) ((Character.digit(hexString.charAt(i), 16) << 4) + Character.digit(hexString.charAt(i + 1), 16)); }//from w ww . j av a 2 s. co m return array; }
From source file:Main.java
static byte[] hexStringToByteArray(String hexString) { int resultLen = hexString.length() / 2; byte[] result = new byte[resultLen]; for (int i = 0; i < resultLen; i++) { result[i] = (byte) ((Character.digit(hexString.charAt(i * 2), 16) << 4) + Character.digit(hexString.charAt((i * 2) + 1), 16)); }//from www .j a va 2 s .c o m return result; }
From source file:Main.java
public static byte[] dehexify(String paramString) { int j = paramString.length(); byte[] arrayOfByte = new byte[j / 2]; int i = 0;//w ww .ja v a 2s. com while (i < j) { arrayOfByte[(i / 2)] = ((byte) ((Character.digit(paramString.charAt(i), 16) << 4) + Character.digit(paramString.charAt(i + 1), 16))); i += 2; } return arrayOfByte; }
From source file:Main.java
public static byte[] hexStringToByteArray(String paramString) { int i = paramString.length(); byte[] arrayOfByte = new byte[i / 2]; for (int j = 0; j < i; j += 2) arrayOfByte[(j / 2)] = ((byte) ((Character.digit(paramString.charAt(j), 16) << 4) + Character.digit(paramString.charAt(j + 1), 16))); return arrayOfByte; }
From source file:Main.java
public static byte[] hexStringToByteArray(String paramString) { int i = paramString.length(); byte[] arrayOfByte = new byte[i / 2]; for (int j = 0; j < i; j += 2) { arrayOfByte[(j / 2)] = ((byte) ((Character.digit(paramString.charAt(j), 16) << 4) + Character.digit(paramString.charAt(j + 1), 16))); }/*w ww . j a v a 2 s . co m*/ return arrayOfByte; }
From source file:Main.java
public static String hexToString(String hex) { StringBuilder sb = new StringBuilder(); char[] hexData = hex.toCharArray(); for (int count = 0; count < hexData.length - 1; count += 2) { int firstDigit = Character.digit(hexData[count], 16); int lastDigit = Character.digit(hexData[count + 1], 16); int decimal = firstDigit * 16 + lastDigit; sb.append((char) decimal); }/*from w ww. j a v a2s . c o m*/ return sb.toString(); }
From source file:Main.java
public static byte[] hexStringToByteArray(String s) { if (s == null) return null; int len = s.length(); byte[] data = new byte[len / 2]; for (int i = 0; i < len; i += 2) { data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16)); }//from w w w .j av a2 s. c o m return data; }
From source file:Main.java
public static byte[] hexToBytes(String s) { int length = s.length(); byte[] data = new byte[length / 2]; for (int index = 0; index < length; index += 2) { data[index / 2] = (byte) ((Character.digit(s.charAt(index), 16) << 4) + Character.digit(s.charAt(index + 1), 16)); }// w w w. j ava 2 s. c om return data; }
From source file:Main.java
public static byte[] hexToBytes(String s) { if (s.length() % 2 == 1) return new byte[0]; int len = s.length(); byte[] data = new byte[len / 2]; for (int i = 0; i < len; i += 2) { data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16)); }/*from ww w . ja v a2 s . c o m*/ return data; }