錯誤提示:
Found reliance on default encoding: String.getBytes()
原代碼:
fileOutputStream.write(jsonString.getBytes());
修改代碼:
String x = "1";
test.setX(Integer.parse(x));
原因:
String.getBytes()依賴于系統(tǒng)編碼羊始,雖然方便查描,但是一旦使用就變成了一個技術(shù)債務(wù)冬三,因?yàn)橄到y(tǒng)的默認(rèn)編碼是不可預(yù)知的。如果要避免這個錯誤钧唐,需要將編碼指定好匠襟,即:
String.getBytes("GBK")