<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                1. try (BufferedWriter bw = new BufferedWriter(new FileWriter(file, append))) 自動關閉文件流 ~~~ package net.aexit.galaxy.earth.common.utils; import java.io.*; import java.util.ArrayList; import java.util.List; /** * Created by dailin on 2018/3/23. * 文件操作工具類 */ public class FilesUtil { /** * 將List數據寫入文件 * @param values 數據 * @param path 文件目錄 * @param append 是否追加 * @throws IOException */ public void writeToFile(List<String> values,String path,Boolean append) throws IOException { File file = new File(path); checkFile(file.getParent(),true); try (BufferedWriter bw = new BufferedWriter(new FileWriter(file, append))) { for (String value : values) { bw.write(value); bw.newLine(); } bw.flush(); } } /** * 將文件轉為List * @param path 文件路徑 * @return 文件行列表 * @throws IOException */ public List<String> readFile(String path) throws IOException { List<String> values = new ArrayList<>(); FileReader fr = new FileReader(path); try (BufferedReader bufr = new BufferedReader(fr)) { String value; while ((value = bufr.readLine()) != null) { values.add(value); } } return values; } /** * 判斷目錄是否存在 * @param path 目錄 * @param mkdir 是否創建目錄 * @return * @throws IOException */ public Boolean checkFile(String path,Boolean mkdir) throws IOException { File paths = new File(path); if(!paths.exists()){ if (mkdir){paths.mkdirs();}; return false; } return true; } } ~~~ 最開始寫入文件的時候沒有判斷目錄是否存在,改正 ~~~ public class TestFile { public static void main(String[] args) { File file = new File("D:\\mmmmmmmmm\\sssss\\ppppppp\\texdddd.txt"); System.out.println(file.getParent()); \\獲取上一級目錄 System.out.println(file.getAbsoluteFile()); System.out.println(file.getAbsolutePath()); } } ~~~ ~~~ D:\mmmmmmmmm\sssss\ppppppp D:\mmmmmmmmm\sssss\ppppppp\texdddd.txt D:\mmmmmmmmm\sssss\ppppppp\texdddd.txt ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看