I need to send a sequence of spaces or zeros, whose size is of fixed byte length. The in house framework I am working with takes care of converting string into bytes as per encoding. So in nutshell I need to create a string of given length.
I found out that one space is of two bytes in Java, but it might differ based on encoding used. I tried ensureCapacity method of byte [] with min length and maximum capacity, but while converting it to String, there are no padding of zeros, even though byte array length is same as maximum capacity I am giving.
I am getting a little confused while trying to grasp the concept of bytes, string, charsets, byte [], new String(byte []), encoding, String.toBytes etc.
How do i go about creating the same. Also if anyone knows a good reference on these topics, please share. I am using Java