| | |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * @param filePath 临时文件的删除 |
| | | * 删除文件夹里面子目录 |
| | | * 再删除文件夹 |
| | | */ |
| | | public static void deleteFiles(String filePath) { |
| | | File file = new File(filePath); |
| | | if ((!file.exists()) || (!file.isDirectory())) { |
| | | |
| | | return; |
| | | } |
| | | String[] tempList = file.list(); |
| | | File temp = null; |
| | | for (int i = 0; i < tempList.length; i++) { |
| | | if (filePath.endsWith(File.separator)) { |
| | | temp = new File(filePath + tempList[i]); |
| | | } else { |
| | | temp = new File(filePath + File.separator + tempList[i]); |
| | | } |
| | | if (temp.isFile()) { |
| | | temp.delete(); |
| | | } |
| | | if (temp.isDirectory()) { |
| | | deleteFiles(filePath + "\\" + tempList[i]); |
| | | } |
| | | } |
| | | // 空文件的删除 |
| | | file.delete(); |
| | | } |
| | | |
| | | // 定义一个公共的静态方法zipFolder,用于压缩文件夹 |
| | | // 参数sourceFolderPath是源文件夹的路径,zipFilePath是压缩后的zip文件路径 |
| | | public static boolean zipFolder(String sourceFolderPath, String zipFilePath) { |