使用Java等同于vis 的字符串需要发生什么
vi
:set nobomb
假设它BOM来自我正在读取的文件。
BOM
Java无法正确处理BOM。实际上,Java像处理其他所有char一样处理BOM。
发现了这一点:
http://www.rgagnon.com/javadetails/java-handle-utf8-file-with- bom.html
public static final String UTF8_BOM = "\uFEFF"; private static String removeUTF8BOM(String s) { if (s.startsWith(UTF8_BOM)) { s = s.substring(1); } return s; }
可能是我改用apache IO:
http://commons.apache.org/proper/commons- io/apidocs/org/apache/commons/io/input/BOMInputStream.html