1.在创建文件的时候报错,路径为多文件
java.util.Date date = new java.util.Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:sss");
String strRecordFile = Environment.getExternalStorageDirectory().getPath() + "/DCIM/ScreenRecorder/" + simpleDateFormat.format(date) + "-start" + ".mp4";
File file = new File(strRecordFile);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
2.解决方法,先创建文件夹,再创建文件
String path1 = Environment.getExternalStorageDirectory().getPath() + "/DCIM/ScreenRecorder/";
File pathfile=new File(path1);
if (!pathfile.exists()){
pathfile.mkdirs();
}
网友评论