我的问题是,当 XML 文件中有 UTF-8 字符时,我的 DOM 解析器无法加载文件现在,我知道我必须给他指示才能读取 utf-8,但我不知道该怎么说在我的代码中是:
File xmlFile = new File(fileName);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(xmlFile);
doc.getDocumentElement().normalize();
我知道有方法 setencoding(),但我不知道将它放在我的代码中的哪个位置...