java去除字符串后面的\0

java去除字符串后面的\0

private String filterCode(String string) {
        if (string != null) {
            string = string.trim();
            byte[] zero = new byte[1];
            zero[0] = (byte) 0;
            String s = new String(zero);
            string = string.replace(s, "");
        }
        return string;
    }

 

你可能感兴趣的:(java去除字符串后面的\0)