在UTF-8编码的Java文件中,删除字符串定义中UTF-8标识符
public static String removeUTF8Signature(String strKey) throws IOException { String resultKey = strKey; int index = 0; DataInputStream dis=new DataInputStream(new ByteArrayInputStream(strKey.getBytes())); while(true) { int bb1 = dis.read(); int bb2 = dis.read(); int bb3 = dis.read(); if (bb1 == 0xef && bb2 == 0xbb && bb3 == 0xbf) { index+=3; } else { break; } } resultKey= new String(strKey.getBytes(), index, strKey.getBytes().length - index); return resultKey; }
浙公网安备 33010602011771号