if (file.exists()) {
//如果文件已存在
} else {
//如果文件目錄不存在,創建文件
String filePath = filePathAndName.substring(0, filePathAndName.lastIndexOf("\\"));
File folder = new File(filePath);
folder.mkdirs();
//如果文件不存在,創建文件
file.createNewFile();
}