報錯信息:
MessageParserUtil.java:122, DM_DEFAULT_ENCODING, Priority: High
Dm: Found reliance on default encoding in com.huawei.nos.nosimsys.parser.MessageParserUtil.parse(File): new java.io.FileReader(File)
Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.
翻譯:
找到一個方法的調用,它將執行一個字節到字符串(或字符串到字節)的轉換,並假定默認的平台編碼是合適的。這會導致應用程序行為在不同平台之間變化。使用替代API並明確指定字符集名稱或字符集對象
源代碼:
1
2
|
//FileReader fileReader = new FileReader(file);
//BufferedReader br = new BufferedReader(fileReader);
|
改為:
1
2
|
InputStreamReader isr =
new
InputStreamReader(
new
FileInputStream(file),
"UTF-8"
);
BufferedReader br =
new
BufferedReader(isr);
|