InputStreamReader ISR = new InputStreamReader (New FileInputStream ("./test/Junk SMS Training set 80W"), "UTF-8");
FileReader FR = new FileReader (New File ("./test/Spam Message training set 80W"));
BufferedReader br = new BufferedReader (ISR);
FileWriter FW = new FileWriter ("./test/Spam Message training set 80W _result.txt"), true);
OutputStreamWriter OSW = new OutputStreamWriter (New FileOutputStream ("./test/Junk SMS Training set 80W _result.txt"), "UTF-8");
BufferedWriter bw = new BufferedWriter (OSW);
The problem is that in the process of FileReader reading a file, FileReader inherits InputStreamReader, but does not implement a constructor with character set parameters in the parent class.
The reason is clear, the problem is not difficult to solve, with inputstreamreader instead of FileReader,
InputStreamReader isr=new InputStreamReader (New FileInputStream (FileName), "UTF-8");
This reads the file directly with the UTF-8 decoding, no longer do the encoding conversion.
Java IO garbled