zoukankan      html  css  js  c++  java
  • 3、循环读取文件夹及文件夹中的文件

     private List<String> getFileList(String path){
            //存放读取出文件的地址路径
            List<String> fileLists = new ArrayList<>();
            try {
                //获取path路径下的内容(文件和文件夹)
                FTPFile[] files = ftpClient.listFiles(path);
                for (int i = 0; i < files.length; i++) {
                    FTPFile file = files[i];
                    if (file.isFile()) {
                        //获取文件或文件夹名称
                        String saveAsFileName = file.getName();
                        String filePath = path + saveAsFileName;
                        fileLists.add(filePath);
                    }else if (file.isDirectory()){
                        //子文件夹下的文件夹路径
                        String childLists = path + file.getName()+ "/";
                        List<String> fileList = getFileList(childLists);
                        this.insertData(fileList);
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            return fileLists;
        }
  • 相关阅读:
    preprocess
    数组
    共用体
    动态内存管理函数
    C链表
    文件的定位与出错检查
    字符串读写函数
    C文件操作
    位运算
    爱好-超级IP:超级IP
  • 原文地址:https://www.cnblogs.com/karlz/p/14356354.html
Copyright © 2011-2022 走看看