简体   繁体   English

如何使用Spring读取文件系统

[英]How to read a file system using Spring

What I need: I need a method that, given a specific directory name on my app, will return his content. 我需要什么:我需要一种方法,给我的应用程序一个特定的目录名称,该方法将返回他的内容。

/root
    /folder1
        /folder11
        /folder12
    /folder2
        /folder21
        /file21.txt
    /folder3
        /file31.txt
        /file32.txt

For example, if I call myMethod("/root"); 例如,如果我调用myMethod("/root"); it will return to me a certain object list containing {'folder1', 'folder2', 'folder3'} . 它会返回给我一个包含{'folder1', 'folder2', 'folder3'}对象列表。 Calling myMethod("/root/folder2"); 调用myMethod("/root/folder2"); will return {'folder21', 'file21.txt'} 将返回{'folder21', 'file21.txt'}

Question: how can I implement this kind of function using Spring? 问题:如何使用Spring实现这种功能?

如果它是目录,则可以使用java.io.File ,并使用docx.list()列出docx.list() ,然后递归地对所有目录子目录执行此操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用阅读器从文件系统读取文本文件(.txt)并将每个文件的文本传递给处理器 spring 批处理? - How to read text files(.txt) from file system using reader and pass each file's text to processor spring batch? 如何使用spring boot读取excel文件 - How to read excel file using spring boot 如何在文件系统中使用Spring框架加载属性文件 - How to load properties file using spring framework in file system 如何使用Eclipse将txt文件作为我的system.in读取 - How to read a txt file as my system.in using eclipse 如何使用java从远程系统读取文件? - How to read a file from remote system using java? 如何使用 Java/Spring 自动管理文件系统目录树? - How to automatically manage a file system directory tree using Java/Spring? 如何在Spring applicationContext中读取系统环境变量 - how to read System environment variable in Spring applicationContext 如何使用spring读取属性文件并暴露给类 - how to read properties file using spring and exposed to class Spring Batch:如何使用FlatFileItemReader读取CSV文件的页脚和验证 - Spring Batch : How to read footer of CSV file and validation using FlatFileItemReader 如何使用Spring框架阅读和上传xls文件? - How to read and upload a xls file using Spring framework?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM