java为什么组织。阿帕奇。薛西斯。解析器。SAXParser在utf8编码的xml中不跳过BOM?
我有一个utf8编码的xml。 这个文件包含了文件的开头。 所以在解析过程中,我面对的是org。xml。萨克斯。SAXParseException:prolog中不允许包含内容。 我无法从文件中删除这3个字节。 我无法将文件加载到内存中并在此处删除它们(文件很大)。 所以出于性能原因,我使用SAX解析器,只想跳过这3个字节,如果它们出现在“”标记之前。 我应该为此继承InputStreamReader吗
我是java新手,请告诉我正确的方法
# 1 楼答案
这之前就出现过,当它发生在我身上时,我在堆栈溢出上发现了the answer。链接答案使用
PushbackInputStream
来测试BOM# 2 楼答案
用法: