Reading degree symbol from .txt file with scanner

I am writing a master program for my simulator. I get briefings in a .txt file, and I'm trying to read a file with a scanner. The .txt file contains a power symbol, and this causes the scanner to read not the entire file.

 public static String[] ConvertFile(String FileName){
    ArrayList<String> FileArray = new ArrayList<String>();
    int count = 0; 

    try{
        Scanner file =  new Scanner( new File ("C:\ <File Location>" + FileName));
        while(file.hasNextLine()){
            count++;
            String Line = file.nextLine());
            System.out.printf("%3d: %s %n", count, Line );
            System.out.println(count);

        }
    }
    catch(FileNotFoundException fnfe){
        System.out.println("File Not Found.");
    }
    return null;
}

Ive put a line in the question below (line 23)

COND:    140475 LB // RWY DRY // +14Β°C  Q1021  270/09  // LMT: OBS(B)

Note that the output prints the first 16 lines of the txt file when there are 726 lines. I know its degree symbol because when I edit txt and delete degree symbols, the program displays all the lines.

+4
source share
2 answers

. , , , 5 , 4 . - , , .

, , Java Scanner . , , :

System.out.println(java.nio.charset.Charset.defaultCharset());

"UTF-8". Windows 10, , , "ANSI". , , Scanner, .

Window notepad, ANSI UTF-8. "", " ...", , , "UTF-8" "".

enter image description here

. . . .

+1

, , , UTF-8, , , UTF-8 UTF-8

0

Source: https://habr.com/ru/post/1666814/


All Articles