List of usage examples for java.lang Character digit
public static int digit(int codePoint, int radix)
From source file:eu.dety.burp.joseph.utilities.Decoder.java
/** * Convert hex string to byte array/* w w w.ja va 2 s . c o m*/ * * @param str * Hex formatted string * @return Byte array */ public static byte[] hexToBytes(String str) { str = str.replace(" ", ""); int len = str.length(); byte[] data = new byte[len / 2]; try { for (int i = 0; i < len; i += 2) { data[i / 2] = (byte) ((Character.digit(str.charAt(i), 16) << 4) + Character.digit(str.charAt(i + 1), 16)); } } catch (Exception e) { data = new byte[0]; } return data; }
From source file:com.jaspersoft.jasperserver.core.util.StringUtil.java
/** * Convert hex string to byte array//from w w w . j av a2s .co m * * @param data input string data * @return bytes */ public static byte[] hexStringToByteArray(String data) { int k = 0; byte[] results = new byte[data.length() / 2]; for (int i = 0; i < data.length();) { results[k] = (byte) (Character.digit(data.charAt(i++), 16) << 4); results[k] += (byte) (Character.digit(data.charAt(i++), 16)); k++; } return results; }
From source file:org.sonar.scanner.scan.filesystem.CharsetValidationTest.java
private static byte[] hexToByte(String str) { String s = StringUtils.deleteWhitespace(str); 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)); }/* w ww . j a va 2 s.c o m*/ return data; }
From source file:cn.caimatou.canting.utils.http.asynchttp.PersistentCookieStore.java
protected byte[] hexStringToByteArray(String s) { 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)); }/*www . j av a 2s.c om*/ return data; }
From source file:bluemurder.miner.MinerTask.java
byte[] hexStringToByteArray(String s) { 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)); }// w w w. j a v a 2 s. c o m return data; }
From source file:org.apache.cassandra.jmeter.AbstractCassandaTestElement.java
private static int charToHexDigit(char ch) throws ParseException { int digit = Character.digit(ch, 16); if (digit == -1) { throw new ParseException("\"" + ch + "\" is an invalid character", 0); }/*from www . j ava2s.c om*/ return digit; }
From source file:UUIDUtils.java
/** * Converts a UID formatted String to a byte[]. The UID must be in the * format generated by createUID, otherwise null is returned. * * @param uid String representing a 128-bit UID. * * @return byte[] 16 bytes in length representing the 128-bits of the * UID or null if the uid could not be converted. */// w w w . ja v a 2 s . com public static byte[] toByteArray(String uid) { if (isUID(uid)) { byte[] result = new byte[16]; char[] chars = uid.toCharArray(); int r = 0; for (int i = 0; i < chars.length; i++) { if (chars[i] == '-') continue; int h1 = Character.digit(chars[i], 16); i++; int h2 = Character.digit(chars[i], 16); result[r++] = (byte) (((h1 << 4) | h2) & 0xFF); } return result; } return null; }
From source file:de.digiway.rapidbreeze.client.infrastructure.cnl.ClickAndLoadHandler.java
private byte[] hexStringToByteArray(String s) { 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)); }// w w w. j a v a 2 s . c o m return data; }
From source file:net.vleu.par.android.rpc.PersistentCookieStore.java
protected 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)); return data;/* www .j av a 2 s . c om*/ }
From source file:CodePointInputMethod.java
private void waitDigit(char c) { if (Character.digit(c, 16) != -1) { buffer.insert(insertionPoint++, c); sendComposedText();/*from ww w.j a v a2s . c o m*/ } else { beep(); } }