So im using a scanner to read a file. However i dont understand that if the file is a UTF-8 file, and the current line being read when iterating over the file, is containing a digit, the method Character.isDigit(line.charAt(0))
returns false. However if the file is not a UTF-8 file the method returns true.
Heres some code
File theFile = new File(pathToFile);
Scanner fileContent = new Scanner(new FileInputStream(theFile), "UTF-8");
while(fileContent.hasNextLine())
{
String line = fileContent.nextLine();
if(Character.isDigit(line.charAt(0)))
{
//When the file being read from is NOT a UTF-8 file, we get down here
}
When using the debugger and looking at the line
String, i can see that in both cases (UTF-8 file or not) the string seems to hold the same, a digit. Why is this happening?