62,614
社区成员
发帖
与我相关
我的任务
分享
File myFile = new File(fileName);
//判断文件是否存在,如果不存在则调用createNewFile()方法创建新目录,否则跳至异常处理代码
if(!myFile.exists())
myFile.createNewFile();
else //如果不存在则扔出异常
throw new Exception("The new file already exists!");