Last active
December 30, 2015 08:09
-
-
Save MangoLiu/7801008 to your computer and use it in GitHub Desktop.
byte ----> 8 bits(输出byte表示的8位bit串)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String byte2bits(byte b) { | |
int z = b; | |
z |= 256; //使最后能截取到8位,而又不影响byte的原来值。 | |
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