我正在尝试按如下方式读取 UTF-8 编码文件-
import java.io.*;
class main {
public static void main(String[] args) throws java.lang.Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("temp.txt"), "UTF-8"));
String line;
line = br.readLine();
line = line.trim();
boolean val1 = line.length() != 0;
boolean val2 = !line.startsWith("//");
System.out.println(val1 + " " + val2);
br.close();
}
}
文件 temp.txt 包含第一行 -
//,<verb>,<verb>
所以,输出应该是
true false
但我得到的输出为
true true
有人可以告诉我如何解决这个问题吗?