• 获取某个文件夹下面的子文件夹(要求是第一级)


    目标:获取前三个文件夹,而且只能是前三个文件夹,要区分文件与文件夹的定义,在前三个文件夹下面各有子文件

     前四张图就是为了证明文件夹的结构,

     代码如下:(部分代码是项目组要求,看起来没用,忽略)

    package com.efounder.finereport.server;

    import java.io.File;

    import com.efounder.eai.framework.JActiveObject;

    public class ESPFineReportDAL extends JActiveObject {

    private static final String GUID = "ESPFineReportDAL";

    public ESPFineReportDAL() {
    setObjectGUID(GUID);
    }
    /**
    * 获取某个文件夹下的子文件夹
    *
    * @param o1
    * @param o2
    * @param o3
    * @param o4
    * @return
    */
    public Object getChildFolder(Object o1, Object o2, Object o3, Object o4) {
    String path = "F:\SVN\EnterpriseServer\WEB-INF\reportlets";
    getFile(path);
    return null;
    }
    private static void getFile(String path) {
    File file = new File(path);
    File[] array = file.listFiles();
    for (int i = 0; i < array.length; i++) {                                                                            //递归
    if (array[i].listFiles().length>0&&"reportlets".equals(array[i].getParentFile().getName())) {               //判断
    System.out.println("文件夾"+array[i].getName());
    String list = array[i].getName();                                                                                                        //放到list里面,
    System.out.println(list);

    }
    }
    }
    public static void main(String[] args) {
    String path = "F:\SVN\EnterpriseServer\WEB-INF\reportlets";
    getFile(path);
    }
    }

  • 相关阅读:
    Chevy equinox
    回家线路
    salesforce account hierarchy
    IOS8 对flex兼容性问题
    Chrome FeHelper 插件下载地址
    vue 项目抛出警告
    vue 干货
    Error in mounted hook: "TypeError: handlers[i].call is not a function" 原因
    vue 路由知识点(一级路由与二级路由嵌套)
    (转)ORA-01940: cannot drop a user that is currently connected 问题解析
  • 原文地址:https://www.cnblogs.com/thomasbc/p/6874366.html
Copyright © 2020-2023  润新知