编程语言
首页 > 编程语言> > 清除目录下的文件 java

清除目录下的文件 java

作者:互联网

    /**
     * clear redundant files
     */
    public static void clearRedundantFiles() {
        String path = "/data/update/";
        File file = new File(path);
        if (!file.exists()) {
            return;
        }

        File fileList[] = file.listFiles();
        for (int i = 0; i < fileList.length; i++) {
            File fileNode = fileList[i];
            if (fileNode.isDirectory()) {
                continue;
            }
            String fileName = fileNode.getName();
            if (fileName.startsWith("meminfo")|| fileName.startsWith("cpuinfo")) {
                Log.info(TAG, "clearRedundantFiles " + path + fileName);
                File fileObj = new File(path + fileName);
                fileObj.delete();
            }
        }
    }

 

标签:java,file,清除,fileList,fileName,File,path,目录,fileNode
来源: https://www.cnblogs.com/wanghaoran/p/16221520.html