From c64f00a1f9a91cb82bd1b8308e0c9b29ef5de76f Mon Sep 17 00:00:00 2001
From: Hunter0x7c7 <1125607007@qq.com>
Date: 星期五, 08 九月 2023 09:24:21 +0800
Subject: [PATCH] 版本v1.0.1(2)发布。
---
src/main/java/com/github/hunter0x7c7/sync/utils/PathUtil.java | 25 +++++++++++--------------
1 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/src/main/java/com/github/hunter0x7c7/sync/utils/PathUtil.java b/src/main/java/com/github/hunter0x7c7/sync/utils/PathUtil.java
index e64898f..9ea1f2c 100644
--- a/src/main/java/com/github/hunter0x7c7/sync/utils/PathUtil.java
+++ b/src/main/java/com/github/hunter0x7c7/sync/utils/PathUtil.java
@@ -2,6 +2,7 @@
import java.io.File;
import java.net.URL;
+import java.net.URLDecoder;
public class PathUtil {
/**
@@ -13,6 +14,10 @@
*/
public static final String projectPath = initProjectPathAndDebug();
+ public static String getConfigFilePath(String cfgName) {
+ return String.format("%s%s%s", projectPath, getFileSeparator(), cfgName);
+ }
+
/***
* 鑾峰彇椤圭洰鏍硅矾寰勶紝鏃犺鏄墦鍖呮垚jar鏂囦欢銆�
* 涓轰簡淇濊瘉璋冭瘯鏃惰幏鍙栭」鐩矾寰勶紝鑰屼笉鏄痓in璺緞锛屽鍔犻�昏緫锛� 濡傛灉浠in鐩綍鎺ワ紝鍒欒繑鍥炰笂涓�灞傜洰褰�
@@ -20,22 +25,10 @@
* @return 渚嬪锛欶:\eclipse\work\JavaFX\AddressApp\build\dist
*/
private static String initProjectPathAndDebug() {
-
- if (SystemUtil.isWindows()) {
- System.out.println(".....isWindows....");
- }
- if (SystemUtil.isMacOs()) {
- System.out.println("....isMacOs.....");
- }
- if (SystemUtil.isLinux()) {
- System.out.println("......isLinux...");
- }
-
-
URL url = PathUtil.class.getProtectionDomain().getCodeSource().getLocation();
String filePath = null;
try {
- filePath = java.net.URLDecoder.decode(url.getPath(), "utf-8");
+ filePath = URLDecoder.decode(url.getPath(), "utf-8");
} catch (Exception e) {
e.printStackTrace();
}
@@ -59,6 +52,10 @@
return null;
}
+ public static String getFileSeparator() {
+ return File.separator;
+ }
+
/***
* 杩欎釜鏂规硶鎵撳寘浣峧ar鏂囦欢灏辨棤娉曡幏鍙栭」鐩矾寰勪簡銆�
* @return
@@ -68,7 +65,7 @@
File file = new File(realPath);
realPath = file.getAbsolutePath();//鍘绘帀浜嗘渶鍓嶉潰鐨勬枩鏉�/
try {
- realPath = java.net.URLDecoder.decode(realPath, "utf-8");
+ realPath = URLDecoder.decode(realPath, "utf-8");
} catch (Exception e) {
e.printStackTrace();
}
--
Gitblit v1.9.1