FileInputStream fileInputStream = new FileInputStream(file);

if(!fileInputStream.closed){
            fileInputStream.close();
}

file.delete();//如果文件流不关闭,会删除不了该文件