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

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