private File getFile(String filePath) {//传入文件路径
File f = new File(filePath);//创建File对象
if (!f.exists()) {//判断f 如果不存在,就创建
try {
f.createNewFile();//创建
} catch (IOException e) {
e.printStackTrace();
}
}
return f;//返回File对象
}
上面就是一个简单的获取某个文件对象的方法. 如果没有就先创建再返回