public static String toBinaryString ( byte [ ] bytes , boolean isMSB ) { StringBuilder sb = new StringBuilder ( ) ; for ( byte b : bytes ) { String binary = String . format ( "%8s" , Integer . toBinaryString ( b & 0xFF ) ) . replace ( ' ' , ' ' ) ; if ( isMSB ) sb . append ( binary ) ; else sb . append ( new StringBuilder ( binary ) . reverse ( ) ) ; } return sb . toString ( ) ; }
Converts a byte array to a binary String .