Why my DOM parser cant read UTF-8

后端 未结 3 1686
鱼传尺愫
鱼传尺愫 2020-12-06 05:59

I have problem that my DOM parser can´t load file when there are UTF-8 characters in XML file Now, i am aware that i have to give him instruction to read utf-8, but i don´t

3条回答
  •  一个人的身影
    2020-12-06 06:30

    Try to use Reader and provide encoding as parameter:

    InputStream inputStream = new FileInputStream(fileName);
    documentBuilder.parse(new InputSource(new InputStreamReader(inputStream, "UTF-8")));
    

提交回复
热议问题