public static String toBinary ( final byte [ ] pBytes ) { String ret = null ; if ( pBytes != null && pBytes . length > 0 ) { BigInteger val = new BigInteger ( bytesToStringNoSpace ( pBytes ) , HEXA ) ; StringBuilder build = new StringBuilder ( val . toString ( 2 ) ) ; // left pad with 0 to fit byte size for ( int i = build . length ( ) ; i < pBytes . length * BitUtils . BYTE_SIZE ; i ++ ) { build . insert ( 0 , 0 ) ; } ret = build . toString ( ) ; } return ret ; }
Convert byte array to binary String