if (!targetFile.exists()){
targetFile.createNewFile();
}
When creating a file, we may be in a series of folders. When the folder does not exist, we cannot create a file
File targetFile = new File(videoFramesPath+File.separator + dir + File.separator + UUID.randomUUID().toString() + ".jpg");
Solution:
judge whether the folder exists before creating the file,
if (!targetFile.getParentFile().exists()){
targetFile.getParentFile().mkdirs();
}
if (!targetFile.exists()){
targetFile.createNewFile();
}