I am trying to read a UTF-8 encoded file as follows-
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();
}
}
File temp.txt contains first line as-
//,<verb>,<verb>
So, the output should be
true false
But I get output as
true true
Can somebody tell me how to fix this?
Open your temp.txt in a text editor and make sure that you don’t have any characters in front of the
//.