I ran into an issue when creating a String from a byte array where values of 0 inside the array are ignored when constructing the string. How can I make it so that if the byte value is 0, the String simply adds a space instead of removing it.
Example, the output of this is DT_TestTracelineCTestTraceli
.
public static void main(String[] args) {
byte[] text = {68, 84, 95, 84, 101, 115, 116, 84, 114, 97, 99, 101, 108, 105, 110, 101, 0, 0, 0, 0, 67, 84, 101, 115, 116, 84, 114, 97, 99, 101, 108, 105};
System.out.println(new String(text));
}
How can I make it so I can separate those two strings using a tab character or uses spaces so the output is DT_TestTraceline CTestTraceli
Thanks