string to byte

Hello,
I know that this topic has been raised before, however, I failed to find the answer i am looking for.
I have the following string:

String S = "0b00001111";

I need it to become the following byte

byte B = 0b00001111;

so that I can later put it into the following array

byte B_array [8] = (0b000000000,
                             0b000000000,
                             0b000000000,
                             0b000000000,
                             0b000000000,
                             0b000000000,
                             0b000000000,
                             0b000000000);

I have already tried this:

B = byte (S.toInt());

and it doesn't work as expected - it just creates a single integer out of the String. (or better it actually works as it says but this is not what I want it to do.
B = byte (S); doesn't work either

I don't think there exists such a function. So you have to interpret it yourself.

Ok, fine, however, is there a way to add bits to a byte? Can I use byte as an array of sorts?

byte B = 0b00011111;

B[2] = 1;

B = 0b10011111;
?

String s = "0b00110011";
byte b = Byte.parseByte(s);

Throws NumberFormatException if the string cannot be parsed.

What's wrong with bitWrite.

Why are you using a String in the first place? Where does the value in the resource-wasting String come from? Sending data intelligently is better than struggling to convert the crap you get to the form you want.

strinda:
Ok, fine, however, is there a way to add bits to a byte? Can I use byte as an array of sorts?

There are ways to add, subtract, shift left, shift right, AND, OR, NAND, NOR, XAND, XOR etc. bits in a byte. You can use a struct to declare names for the bits in a byte, and access them by name.