List of usage examples for java.lang Integer byteValue
public byte byteValue()
From source file:Main.java
public static void main(String[] args) { Integer integerObject = new Integer("1234567"); byte b = integerObject.byteValue(); System.out.println("byte:" + b); }
From source file:UnboxingError.java
public static void main(String args[]) { Integer iOb = 1000; // autobox the value 1000 int i = iOb.byteValue(); // manually unbox as byte !!! System.out.println(i); // does not display 1000 ! }
From source file:Main.java
public static void main(String[] args) { Integer intObj = new Integer("10"); byte b = intObj.byteValue(); System.out.println(b);//from w w w . java 2 s .co m short s = intObj.shortValue(); System.out.println(s); int i = intObj.intValue(); System.out.println(i); float f = intObj.floatValue(); System.out.println(f); double d = intObj.doubleValue(); System.out.println(d); }
From source file:Main.java
public static void main(String[] args) { Integer intObj = Integer.valueOf(100); // Gets byte from Integer byte b = intObj.byteValue(); // Gets double from Integer double dd = intObj.doubleValue(); System.out.println("intObj = " + intObj); System.out.println("byte from intObj = " + b); System.out.println("double from intObj = " + dd); // Creates a Double object Double doubleObj = Double.valueOf("123.45"); // Gets different types of primitive values from Double double d = doubleObj.doubleValue(); float f = doubleObj.floatValue(); int i = doubleObj.intValue(); long l = doubleObj.longValue(); System.out.println("doubleObj = " + doubleObj); System.out.println("double from doubleObj = " + d); System.out.println("float from doubleObj = " + f); System.out.println("int from doubleObj = " + i); System.out.println("long from doubleObj = " + l); }
From source file:Main.java
public static Byte bytesToInt8(byte bytes[]) { Integer value = 0; for (int i = 0; (i < 1 && i < bytes.length); ++i) { value = value | ((bytes[i] & 0x000000FF) << 8 * i); }//from w w w . j a v a2 s. c o m return value.byteValue(); }
From source file:org.demo.des3.DESUtils.java
public static byte[] getKeyByStr(String str) { byte bRet[] = new byte[str.length() / 2]; for (int i = 0; i < str.length() / 2; i++) { Integer itg = new Integer(16 * getChrInt(str.charAt(2 * i)) + getChrInt(str.charAt(2 * i + 1))); bRet[i] = itg.byteValue(); }/* w ww . j av a2 s .co m*/ return bRet; }
From source file:com.alliander.osgp.oslp.OslpUtils.java
/** * Converts an {@link Integer} to a {@link ByteString}. * * @param i/*from w w w. j av a2 s .co m*/ * the {@link Integer} to convert. * @return the {@link ByteString}. * @throws IllegalArgumentException * thrown when i is null. */ public static ByteString integerToByteString(final Integer i) { if (i == null) { throw new IllegalArgumentException("Null cannot be converted to ByteString."); } return ByteString.copyFrom(new byte[] { i.byteValue() }); }
From source file:com.cherong.mock.common.base.util.EncryptionUtil.java
/** * byte ??//from ww w .j a v a2 s. c o m * * @param str * 16 * @return */ private static byte[] string2Byte(String str) { byte[] byt = new byte[str.length() / 2]; for (int i = 0; i < byt.length / 2; i++) { Integer itg = new Integer( 16 * BinaryUtil.hex2Decimal(str.charAt(2 * i)) + BinaryUtil.hex2Decimal(str.charAt(2 * i + 1))); byt[i] = itg.byteValue(); } return byt; }
From source file:org.basdroid.common.NetworkUtils.java
public static byte[] getHexDecimalMacAddress(Context context, String macAddressString) { if (StringUtils.isEmptyString(macAddressString)) { return null; }//from w w w .j a v a 2 s . co m String[] macAddressParts = macAddressString.split(":"); // convert hex string to byte values byte[] macAddressBytes = new byte[6]; // mac.length == 6 bytes for (int i = 0; i < macAddressParts.length; i++) { Integer hex = Integer.parseInt(macAddressParts[i], 16); macAddressBytes[i] = hex.byteValue(); } return macAddressBytes; }
From source file:org.basdroid.common.NetworkUtils.java
public static byte[] getHexDecimalMacAddress(Context context) { String macAddress = getMacAddress(context); if (StringUtils.isEmptyString(macAddress)) { return null; }//from w ww. j a v a2 s. c o m String[] macAddressParts = macAddress.split(":"); // convert hex string to byte values byte[] macAddressBytes = new byte[6]; // mac.length == 6 bytes for (int i = 0; i < macAddressParts.length; i++) { Integer hex = Integer.parseInt(macAddressParts[i], 16); macAddressBytes[i] = hex.byteValue(); } return macAddressBytes; }