From d22349714c8d199c02f336f90fba841ef8f5cd39 Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期五, 21 十一月 2025 17:46:23 +0800
Subject: [PATCH] 优化内存后最终版202511211746
---
src/dialog/Errlog.java | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/xitongshezhi/Charulog.java b/src/dialog/Errlog.java
similarity index 91%
copy from src/xitongshezhi/Charulog.java
copy to src/dialog/Errlog.java
index 9015ef5..da59a46 100644
--- a/src/xitongshezhi/Charulog.java
+++ b/src/dialog/Errlog.java
@@ -1,12 +1,12 @@
-package xitongshezhi;
+package dialog;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
-public class Charulog {
- private static final String LOG_FILE = "log.properties";
+public class Errlog {
+ private static final String LOG_FILE = "err.properties";
private static final int MAX_RECORDS = 500;
private static final ReentrantLock lock = new ReentrantLock();
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -51,8 +51,9 @@
File file = new File(LOG_FILE);
if (file.exists()) {
- try (FileInputStream fis = new FileInputStream(file)) {
- props.load(fis);
+ try (FileInputStream fis = new FileInputStream(file);
+ InputStreamReader isr = new InputStreamReader(fis, "UTF-8")) {
+ props.load(isr);
} catch (IOException e) {
System.err.println("璇诲彇鏃ュ織鏂囦欢澶辫触: " + e.getMessage());
}
@@ -95,14 +96,14 @@
* 鍐欏叆鏃ュ織鏂囦欢
*/
private static void writeLogFile(Properties props) {
- try (FileOutputStream fos = new FileOutputStream(LOG_FILE)) {
+ try (FileOutputStream fos = new FileOutputStream(LOG_FILE);
+ OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8")) {
// 娣诲姞鏂囦欢澶存敞閲�
- props.store(fos, "鎿嶄綔鏃ュ織璁板綍 - 鏈�鍚庢洿鏂�: " + new Date());
+ props.store(osw, "鎿嶄綔鏃ュ織璁板綍 - 鏈�鍚庢洿鏂�: " + new Date());
} catch (IOException e) {
System.err.println("鍐欏叆鏃ュ織鏂囦欢澶辫触: " + e.getMessage());
}
}
-
/**
* 鑾峰彇褰撳墠鏃ュ織璁板綍鏁伴噺锛堢敤浜庢祴璇曪級
*/
--
Gitblit v1.9.3