View plaincopy to clipboardprint?
- Public class bytetobinary {
- /**
- * Convert the byte array to a binary string.
- * @ Param Barr
- * @ Return
- */
- Public String getbinarystrfrombytearr (byte [] Barr ){
- String result = "";
- For (byte B: Barr ){
- Result + = getbinarystrfrombyte (B );
- }
- Return result;
- }
- /**
- * Convert byte into a binary string
- * @ Param B
- * @ Return
- */
- Public String getbinarystrfrombyte (byte B ){
- String result = "";
- Byte A = B ;;
- For (INT I = 0; I <8; I ++ ){
- Byte c =;
- A = (byte) (a> 1); // The result of moving one digit is as if dividing the number of decimal places by 2 and removing the remainder.
- A = (byte) (a <1 );
- If (A = c ){
- Result = "0" + result;
- } Else {
- Result = "1" + result;
- }
- A = (byte) (a> 1 );
- }
- Return result;
- }
- /**
- * Convert byte into a binary string
- * @ Param B
- * @ Return
- */
- Public String getbinarystrfrombyte2 (byte B ){
- String result = "";
- Byte A = B ;;
- For (INT I = 0; I <8; I ++ ){
- Result = (a % 2) + result;
- A = (byte) (a> 1 );
- }
- Return result;
- }
- /**
- * Convert byte into a binary string
- * @ Param B
- * @ Return
- */
- Public String getbinarystrfrombyte3 (byte B ){
- String result = "";
- Byte A = B ;;
- For (INT I = 0; I <8; I ++ ){
- Result = (a % 2) + result;
- A = (byte) (a/2 );
- }
- Return result;
- }
- }