解决时间同步性解析文件中文乱码

master
dongpengju 4 months ago
parent f4a6476e1b
commit bc12bbfde5
  1. 11
      motor-system/src/main/java/com/motor/system/service/impl/StationMachineServiceImpl.java

@ -26,10 +26,8 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -341,7 +339,8 @@ public class StationMachineServiceImpl implements IStationMachineService {
BufferedReader reader;
try {
StringBuilder content = new StringBuilder();
reader = new BufferedReader(new FileReader(filePathName));
InputStreamReader isr = new InputStreamReader(new FileInputStream(filePathName), "UTF-8");
reader = new BufferedReader(isr);
String line = null;
while ((line = reader.readLine()) != null) {
content.append(line);
@ -350,7 +349,7 @@ public class StationMachineServiceImpl implements IStationMachineService {
strList.add(content);
reader.close();
return strList;
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace();
System.out.println("文件不存在");
return strList;

Loading…
Cancel
Save