创建文件夹和文件的方法

String path="d://yourfolder";
String filename="youfilename.txt";
File folder=new File(path);
if(!folder.exists()){//判断文件夹是否存在,不存在就建立个目录
folder.mkdirs();
}
File file=new File(path+File.separator+filename);
try{
if(!file.exists()) //判断是否存在
file.createNewFile();
}
catch(Exception e){}
 

你可能感兴趣的:(文件夹)