中文乱码

This commit is contained in:
qiminbao
2025-10-28 17:34:59 +08:00
parent 72af737163
commit 1a58e37e7c
@@ -27,9 +27,8 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.time.LocalDateTime;
import java.util.*;
@@ -1021,17 +1020,14 @@ public class AgentServiceImpl implements AgentService {
}
}
Properties props = new Properties();
try (InputStream input = Files.newInputStream(path)) {
// 加载配置文件
props.load(input);
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8)) { // 明确指定 UTF-8 编码
props.load(reader);
result = props.getProperty("logicalNode", "");
System.out.println("配置文件加载成功");
GlobalConfig.LOGICAL_NODE_LAST_TIME = lastTime;
GlobalConfig.LOGICAL_NODE = result;
} catch (IOException e) {
System.err.println("无法加载配置文件,使用默认值");
} catch (NumberFormatException e) {
System.err.println("配置文件格式错误: " + e.getMessage());
System.err.println("读取文件失败: " + e.getMessage());
e.printStackTrace();
}
return result;
}