Reputation: 704
I need to append character that 00000000 in byte in String builder. I need to put it into String Array and and read it again later. Example :
StringBuilder sBfNumRow = new StringBuilder();
sBfNumRow.append(""); //add char that 00000000 in byte
stObj [c] = sBfNumRow.toString(); // put into String array
stObj [c] .getBytes // read it again later.
Can someone help me to do this?
Upvotes: 4
Views: 3131
Reputation:
A char and int can be casted to each other so use that technique.
To illustrate.
int a = 0;
char zero = a;
Or use 0 direct without '0'
char zero = 0;
And in your code it would be.
BfNumRow.append((char) 0); //add char that 00000000 in byte
Edit: New answer provided thoughts to improve my answer
Upvotes: 1
Reputation: 10762
That would be
BfNumRow.append((char) 0);
if you want specifically use the char type. This
BfNumRow.append(0);
will use StringBuilder.append(int)
.
Upvotes: 1