List of utility methods to do Byte Create
Object | toByte(Object value) to Byte if (value instanceof Number) { return ((Number) value).byteValue(); if (value instanceof String && !((String) value).isEmpty()) { return Byte.valueOf((String) value); return null; |
Byte | toByte(Object value) Convert an Object to a Byte. if (value == null) return null; if (value instanceof Byte) return (Byte) value; if (value instanceof String) { if ("".equals((String) value)) return null; return new Byte((String) value); ... |
byte | toByte(short unsignedByte) Converts a short containing an unsigned byte value to the corresponding signed byte value and returns the result as a byte if (unsignedByte < 0 || unsignedByte > MAX_BYTE) { throw new IllegalArgumentException(String.format( "Unsigned byte values should be in the range 0..%1$d, got: %2$d", MAX_BYTE, unsignedByte)); return (byte) unsignedByte; |
byte | toByte(short value, boolean first) to Byte if (first) return (byte) (0xff & (value >> 8)); return (byte) (0xff & value); |
byte | toByte(String hex) to Byte return (byte) Integer.parseInt(hex, 16); |
byte | toByte(String hex) to Byte char[] lowChar = { '#', '0' }; char[] highChar = { '#', '0' }; int start = 0; if (hex.startsWith("#")) start = 1; else if (hex.startsWith("0x")) start = 2; if (hex.length() > start + 1) { ... |
byte | toByte(String hex) returns byte of given hex string expression. if (hex.startsWith(HEX_PREFIX)) { hex = hex.replace(HEX_PREFIX, ""); int i = Integer.parseInt(hex, 16); return (byte) i; |
byte[] | toByte(String hexStr) to Byte byte digest[] = new byte[hexStr.length() / 2]; for (int i = 0; i < digest.length; i++) { String byteString = hexStr.substring(2 * i, 2 * i + 2); int byteValue = Integer.parseInt(byteString, 16); digest[i] = (byte) byteValue; return digest; |
byte[] | toByte(String hexString) to Byte int len = hexString.length() / 2; byte[] result = new byte[len]; for (int i = 0; i < len; i++) result[i] = Integer.valueOf(hexString.substring(2 * i, 2 * i + 2), 16).byteValue(); return result; |
byte | toByte(String str) Convert a If the string is NumberUtils.toByte(null) = 0 NumberUtils.toByte("") = 0 NumberUtils.toByte("1") = 1 return toByte(str, (byte) 0); |