i am working on a project that gets the data from the file into a byte array and adds “0” to that byte array until the length of the byte array is 224 bits. I was able to add zero’s but i am unable to confirm that how many zero’s are sufficient. So i want to print the file data in the byte array in binary format. Can anyone help me?
Share
For each byte:
int(happens in the next step via automatic widening ofbytetoint)Integer.toBinaryString()to produce a 9-bit StringString#substring(1)to “delete” the leading “1”, leaving exactly 8 binary characters (with leading zeroes, if any, intact)Which as code is:
Output of above code (always 8-bits wide):