• java文件夹遍历


    Java遍历文件夹

    import java.io.File;
    import java.util.ArrayList;

    public class FileUtil {
        
    private static ArrayList filelist = new ArrayList();

        
    public static void main(String[] args) {
            
    long a = System.currentTimeMillis();
            refreshFileList(
    "c:\\java");
            System.out.println(System.currentTimeMillis() 
    - a);
        }

            
    //遍历文件夹
        public static void refreshFileList(String strPath) {
            File dir 
    = new File(strPath);
            File[] files 
    = dir.listFiles();
            
    if (files == null) {
                
    return;
            }
            
    for (int i = 0; i < files.length; i++) {
                
    if (files[i].isDirectory()) {
                    refreshFileList(files[i].getAbsolutePath());
                } 
    else {
                    String strFileName 
    = files[i].getAbsolutePath().toLowerCase();
                    System.out.println(
    "---" + strFileName);
                    filelist.add(files[i].getAbsolutePath());
                }
            }
        }
        
            
    /**
         * 获取上传文件夹 -- added by dingzh@2010.04.14
         * 
    @return
         * 
    @throws Exception
         
    */
        
    public String getUploadFolder() throws Exception {
            String uploadPath 
    = SystemConfig.getParameter("baseex.uploadfiles.path");
            
    try {
                java.io.File myFilePath 
    = new java.io.File(uploadPath);
                
    if(!myFilePath.exists())
                    myFilePath.mkdir();
            }
            
    catch(Exception e) {
                
    throw e;
            }
            
    return uploadPath;
        }

    }
  • 相关阅读:
    ajax基础
    Linux经常使用命令大全
    基于Proxy思想的Android插件框架
    linux date -d 的一些使用方法
    Mac电脑没有声音,苹果电脑没有声音怎么办
    通用PE u盘装Ghost Win7系统
    通用PE u盘启动盘制作
    Qt for iOS,Qt 与Objective C混合编程
    苹果开发工具:Xcode和Interface Builder
    IOS 使用Interface Builder开发界面入门与技巧
  • 原文地址:https://www.cnblogs.com/ding0910/p/1785436.html
Copyright © 2020-2023  润新知