Hi all,
I am trying to convert a null terminated ascii string stored in a byte array to a java String. When I pass the byte array to the String constructor it
does not detect/interpret the null as a terminator for the ascii string. Is this something I have to manually program in? ie Check for where the null is and then
pass that subarray of everything before the null to the String constructor?
example of problem
// A B C D null F (note F is junk in the array, and should be ignored since it is after null)
byte[] asciiArray = { 65, 66, 67, 68, 0, 70 };
System.out.println(new String(asciiArray, "UTF-8"));
//this prints ABCD"sqare icon"F