Here you can find the source of intToByte(int i)
public static byte intToByte(int i)
//package com.java2s; //License from project: BSD License public class Main { public static byte intToByte(int i) { if (i < 255) { return (byte) (i & 0xFF); } else {/*from w w w . j a v a 2 s .c o m*/ throw new NumberFormatException("Integer is more than 255 !"); } } }