最佳答案
我正在通过 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>