Skip to content

Commit 90e2bc8

Browse files
committed
fix: 修复 Java 8 兼容性问题
- Files.writeString() -> Files.write(path, bytes) - Files.readString() -> new String(Files.readAllBytes(path)) - Path.of() -> Paths.get()
1 parent fb2afb5 commit 90e2bc8

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/main/java/com/github/balloonupdate/mcpatch/client/selfupdate/SelfUpdateDownloader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public static void createUpdateMarker(Path newJarPath) throws Exception {
163163
content.append("path=").append(newJarPath.toAbsolutePath()).append("\n");
164164
content.append("time=").append(System.currentTimeMillis()).append("\n");
165165

166-
Files.writeString(markerFile, content.toString());
166+
Files.write(markerFile, content.toString().getBytes());
167167

168168
Log.debug("已创建更新标记文件: " + markerFile);
169169
}

src/main/java/com/github/balloonupdate/mcpatch/client/selfupdate/SelfUpdateInstaller.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.io.StringReader;
88
import java.nio.file.Files;
99
import java.nio.file.Path;
10+
import java.nio.file.Paths;
1011
import java.nio.file.StandardCopyOption;
1112

1213
/**
@@ -34,7 +35,7 @@ public static boolean installPendingUpdate() {
3435
Log.debug("读取标记文件: " + markerFile);
3536

3637
// 解析标记文件
37-
String markerContent = Files.readString(markerFile);
38+
String markerContent = new String(Files.readAllBytes(markerFile));
3839
Path newJarPath = parseMarkerFile(markerContent);
3940

4041
if (newJarPath == null) {
@@ -113,15 +114,15 @@ private static Path parseMarkerFile(String content) {
113114

114115
while ((line = reader.readLine()) != null) {
115116
if (line.startsWith("path=")) {
116-
jarPath = Path.of(line.substring(5).trim());
117+
jarPath = Paths.get(line.substring(5).trim());
117118
}
118119
}
119120

120121
// 如果没有 path= 格式,尝试直接作为路径解析(旧格式兼容)
121122
if (jarPath == null && !content.trim().isEmpty()) {
122123
String firstLine = content.split("\n")[0].trim();
123124
if (!firstLine.isEmpty()) {
124-
jarPath = Path.of(firstLine);
125+
jarPath = Paths.get(firstLine);
125126
}
126127
}
127128

0 commit comments

Comments
 (0)