form where did you bring the Integer.byteValue(int) method?!!
It's not exist in the Integer class, there is a method with byteValue() with no arguments, for any help about classes and methods of the J2SE refer to the online API documentations
http://java.sun.com/reference/api/index.html
or download it
http://java.sun.com/j2se/downloads/index.html
use type casting
int num = 0;
byte b = (int) num;
Note: int is 4 bytes, where byte is only one byte, so casting int to byte maybe lossy is the int contains number that byte can't hold, refer to reference about conversion and casting for more help
Mohammed Saleem
You can use the ByteBuffer class or use shifting./* ByteBuffer */
public static byte[] toByteArray(int v) {
ByteBuffer bb = ByteBuffer.allocate(4);
bb.putInt(v);
return bb.array();
}
/* Shifting */
public static byte[] toByteArray(int v) {
byte[] result = new byte[4];
result[0] = (byte) (v >>> 24);
result[1] = (byte) (v >>> 16);
result[2] = (byte) (v >>> 8);
result[3] = (byte) v;
return result;
}