我通过FileReader读取文件,该文件已用UTF-8解码(带BOM)。现在我的问题是:我读取文件并输出一个字符串,但不幸的是BOM标记也被输出了。为什么会发生这种情况?
fr = new FileReader(file);
br = new BufferedReader(fr);
String tmp = null;
while ((tmp = br.readLine()) != null) {
String text;
text = new String(tmp.getBytes(), "UTF-8");
content += text + System.getProperty("line.separator");
}
第一行之后的输出
?<style>