浏览代码

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

dengsixing 2 年之前
父节点
当前提交
5fef54250c
共有 1 个文件被更改,包括 14 次插入0 次删除
  1. 14 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/FileUtils.java

+ 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;
+    }
+
 
 }