將想法與焦點(diǎn)和您一起共享

java刪除目錄或文件的方法代碼發(fā)布者:本站     時(shí)間:2020-05-06 14:05:24

java刪除目錄或文件的代碼如下

 
public static void delAllFile(String path) {
        File file = new File(path);
        if (!file.exists()) {
            return;
        }
        if (!file.isDirectory()) {
            return;
        }
        String[] tempList = file.list();
        File temp = null;
        for (int i = 0; i < tempList.length; i++) {
            if (path.endsWith(File.separator)) {
                temp = new File(path + tempList);
            } else {
                temp = new File(path + File.separator + tempList);
            }
            if (temp.isFile()) {
                temp.delete();
            }
            if (temp.isDirectory()) {
                delAllFile(path + "/" + tempList);// 先刪除文件夾里面的文件
                delFolder(path + "/" + tempList);// 再刪除空文件夾
            }
        }
    }



選擇我們,優(yōu)質(zhì)服務(wù),不容錯過(guò)
1. 優(yōu)秀的網(wǎng)絡(luò )資源,強大的網(wǎng)站優(yōu)化技術(shù),穩定的網(wǎng)站和速度保證
2. 15年上海網(wǎng)站建設經(jīng)驗,優(yōu)秀的技術(shù)和設計水平,更放心
3. 全程省心服務(wù),不必擔心自己不懂網(wǎng)絡(luò ),更省心。
------------------------------------------------------------
24小時(shí)聯(lián)系電話(huà):021-58370032
最新国产精品第二页_色资源av中文无码先锋_中国xx爽69护士_日韩欧美亚洲每日更新在线观看