added Util.nullTerminatedCharArrayToString

This commit is contained in:
DaniTheSkunk 2022-09-27 00:57:16 +02:00
parent febe5786b9
commit edd4b2bc56
1 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,14 @@
package com.danitheskunk.skunkworks;
public class Util {
public static String nullTerminatedCharArrayToString(char[] chars) {
int len = chars.length;
for(int i = 0; i < chars.length; ++i) {
if(chars[i] == '\0') {
len = i;
break;
}
}
return new String(chars, 0, len);
}
}