فهرست منبع

update TextFile

reghao 6 ماه پیش
والد
کامیت
6ea16aea22
1فایلهای تغییر یافته به همراه6 افزوده شده و 1 حذف شده
  1. 6 1
      jdk/src/main/java/cn/reghao/jutil/jdk/text/TextFile.java

+ 6 - 1
jdk/src/main/java/cn/reghao/jutil/jdk/text/TextFile.java

@@ -34,6 +34,11 @@ public class TextFile {
      * @date 2019-09-02 上午12:22
      */
     public List<String> read(String filePath) {
+        String charset = "utf-8";
+        return read(filePath, charset);
+    }
+
+    public List<String> read(String filePath, String charset) {
         File file = new File(filePath);
         if (!file.exists()) {
             return null;
@@ -41,7 +46,7 @@ public class TextFile {
 
         List<String> lines = new ArrayList<>();
         try {
-            BufferedReader in =  new BufferedReader(new InputStreamReader(new FileInputStream(file)), bufSize);
+            BufferedReader in =  new BufferedReader(new InputStreamReader(new FileInputStream(file), charset), bufSize);
             String line;
             while ((line = in.readLine()) != null) {
                 lines.add(clearWhiteSpace(line));