[英]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.