Skip to content

Instantly share code, notes, and snippets.

@XJTU-USTC
Last active December 30, 2015 03:19
Show Gist options
  • Select an option

  • Save XJTU-USTC/7768866 to your computer and use it in GitHub Desktop.

Select an option

Save XJTU-USTC/7768866 to your computer and use it in GitHub Desktop.
将byte类型值转换为8位的二进制字符串
public static String byte2bits(byte b) {
int z = b;
z |= 256;
String str = Integer.toBinaryString(z);
int len = str.length();
return str.substring(len-8, len);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment