As an input I have binary string String a = "100110"
. As output I need to have binary byte array byte[] b = {1,0,0,1,1,0}
.
For now I'm using
for (int i=0; i<a.length; i++) {
b[i]= Byte.parseByte(a.substring(i, i+1));
}
But this approach is too slow. Can any one give a better suggestion? Thank you