UTF-8 text file format program read exception

Recently created directly on the windows server and Hand input configuration parameters, such as setting the probability of 0.6, and then open the java program reads the parameters in the local test environment linux completely normal, but put on a server, they reported NotNumber wrong view under the code: double percent = Double.paseDouble (FileUtil.readTxt (...)), found no problems, baffled. So to read from the file to print the log parameters, the results show the contents of the log I was stunned to read the contents of the file actually is? 0.6.

This problem did not get to know, first put aside temporarily, because there have been prior experience json configuration file, so I decided to use this configuration also use json format text, change the 0.6 { "percent": 0.6} After surprisingly, can normal reading.

After changing a way to solve this problem, I was a little curious about the bug, online search, I Daniel's profile, get more consistent answer is that Microsoft text files UTF-8 format had a "special" processing, at the beginning of each file added 0xefbbbf, so when the program reads the file? He came out. This argument seems plausible, but why I can properly read a string json format it? why?

Guess you like

Origin www.cnblogs.com/chen-proj/p/10929152.html