Java如何判断文件夹是否存在?

如题所述

方法如下:

public static void judeDirExists(File file)

if (file.exists())             if (file.isDirectory())                

System.out.println("dir exists");          }

else                 System.out.println("the same name file exists, can not create dir");             }41      

else             System.out.println("dir not exists, create it ...");             、

file.mkdir();

Java是一种可以撰写跨平台应用软件的面向对象的程序设计语言。Java 技术具有卓越的通用性、高效性、平台移植性和安全性,广泛应用于PC、数据中心、游戏控制台、科学超级计算机、移动电话和互联网,同时拥有全球最大的开发者专业社群。

温馨提示:答案为网友推荐,仅供参考