Sfoglia il codice sorgente

文件工具类增加读取文件方法

dengsixing 2 anni fa
parent
commit
5fef54250c

+ 14 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/FileUtils.java

@@ -899,5 +899,19 @@ public class FileUtils {
         }
     }
 
+    /**
+     * utf-8格式读取文件,若文件不存在或者读取文件异常,返回null
+     * @param path
+     * @return
+     */
+    public static String readUtf8String(String path){
+        try {
+            return FileUtil.readUtf8String(path);
+        }catch (Exception e){
+            log.warn("读取文件失败,path:{}", path);
+        }
+        return null;
+    }
+
 
 }