parameter) {
+ String templateContent = ConfigFileUtil.readFileContent(templateFilePath);
+ return ConfigFileUtil.replace(templateContent, parameter);
+ }
+
+ /**
+ * 读取xml配置文件
+ *
+ * @param filePath 文件相对于resources文件夹的相对路径
+ * @return
+ */
+ public static String readFileContent(String filePath) {
+ String resourcePath = CommonMethod.getResFileAbsPath(filePath);
+
+ // 读取指定文件路径的文件内容
+ String contentStr = "";
+ try {
+ Path path = Paths.get(resourcePath);
+ contentStr = new String(Files.readAllBytes(path));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return contentStr;
+ }
+
+ /**
+ * 替换 占位符变量固定为 ${}格式
+ *
+ * @param source 源内容
+ * @param parameter 占位符参数
+ *
+ * 转义符默认为'$'。如果这个字符放在一个变量引用之前,这个引用将被忽略,不会被替换 如$${a}将直接输出${a}
+ * @return
+ */
+ public static String replace(String source, Map parameter) {
+ return replace(source, parameter, "${", "}", false);
+ }
+
+ /**
+ * 替换
+ *
+ * @param source 源内容
+ * @param parameter 占位符参数
+ * @param prefix 占位符前缀 例如:${
+ * @param suffix 占位符后缀 例如:}
+ * @param enableSubstitutionInVariables 是否在变量名称中进行替换 例如:${system-${版本}}
+ *
+ * 转义符默认为'$'。如果这个字符放在一个变量引用之前,这个引用将被忽略,不会被替换 如$${a}将直接输出${a}
+ * @return
+ */
+ public static String replace(String source, Map parameter, String prefix, String suffix, boolean enableSubstitutionInVariables) {
+ //StrSubstitutor不是线程安全的类
+ StrSubstitutor strSubstitutor = new StrSubstitutor(parameter, prefix, suffix);
+ //是否在变量名称中进行替换
+ strSubstitutor.setEnableSubstitutionInVariables(enableSubstitutionInVariables);
+ return strSubstitutor.replace(source);
+ }
+
+}
diff --git a/src/main/java/net/javase/hksup/starter/utils/SystemUtil.java b/src/main/java/net/javase/hksup/starter/utils/SystemUtil.java
new file mode 100755
index 0000000..df521d1
--- /dev/null
+++ b/src/main/java/net/javase/hksup/starter/utils/SystemUtil.java
@@ -0,0 +1,24 @@
+package net.javase.hksup.starter.utils;
+
+public class SystemUtil {
+
+ public static final String OS_NAME = System.getProperty("os.name");
+
+ public static boolean isLinux() {
+ return OS_NAME.toLowerCase().contains("linux");
+ }
+
+ public static boolean isWindows() {
+ return OS_NAME.toLowerCase().contains("windows");
+ }
+
+ public static String userDir() {
+ return System.getProperty("user.dir");
+ }
+
+ public static void jnaDebugLoad(boolean flag) {
+ if (flag) {
+ System.setProperty("jna.debug_load", "true");
+ }
+ }
+}