Forráskód Böngészése

3/25 权要解析

lwhhszx 1 éve
szülő
commit
1b61594dab

+ 18 - 0
src/main/java/cn/cslg/pas/common/utils/BackupUtils.java

@@ -0,0 +1,18 @@
+package cn.cslg.pas.common.utils;
+
+import cn.hutool.core.io.FileUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.system.ApplicationHome;
+import org.springframework.stereotype.Component;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+@Slf4j
+public class BackupUtils {
+
+
+}

+ 29 - 0
src/main/java/cn/cslg/pas/common/utils/FileUtils.java

@@ -45,6 +45,35 @@ public class FileUtils {
         return rootPath;
     }
 
+    public String analysisJsonFile() {
+        ApplicationHome ah = new ApplicationHome(BackupUtils.class);
+        File file = ah.getSource();
+        String settingFilePath = file.getParentFile().toString() + FileUtils.FILE_SEPARATOR + "uploadSetting.json";
+        BufferedReader reader = null;
+        StringBuilder last = new StringBuilder();
+        InputStreamReader inputStreamReader;
+        try (FileInputStream fileInputStream = new FileInputStream(settingFilePath)) {
+            inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8);
+
+            reader = new BufferedReader(inputStreamReader);
+            String tempString;
+            while ((tempString = reader.readLine()) != null) {
+                last.append(tempString);
+            }
+            reader.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (reader != null) {
+                try {
+                    reader.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return last.toString();
+    }
 
     public static   File  getFileByBytes(byte[] bytes, String prefix, String suffix) {
         BufferedOutputStream bos = null;