Java如何在不存在文件夾的目錄下創建文件

今天用到的,就隨手進入我的囊中。

String outPutPath="F:\\a.txt";File fileNew = new File(outPutPath);
File fileParent = fileNew.getParentFile();
if(!fileParent.exists()){
    fileParent.mkdirs();
}
fileNew.createNewFile();

 

轉載:https://www.jb51.net/article/120931.htm

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章