public class Test4{
public static void main( String[] args ) throws Exception{
byte b = -127;
int i = b<0?b+256:b;
System.out.println( Integer.toBinaryString( i ) );
}
}
static String getBinaryFromByte(byte b) {
StringBuffer sb = new StringBuffer();
for (int i = 7; i >=0; i--) {
sb.append(((b&(1<<i))!=0)?'1':'0');
}
return sb.toString();
}