简体   繁体   English

程序将文件夹的特定路径打印到Java中的下一个子文件夹中

[英]Program To print specific path of folder into its next sub folder in java

Create below file and folder on your desktop except that do not assume the depth of the structure is fixed meaning there could be more folders such as T5, T6 etc. 在桌面上创建以下文件和文件夹,除非不假定结构的深度是固定的,这意味着可能会有更多的文件夹,例如T5,T6等。

Write a function to display path of all files in the folder relative to the first file encountered in that folder. 编写一个函数来显示文件夹中所有文件相对于该文件夹中遇到的第一个文件的路径。 Write each path on separate line and also include name of the first file. 将每个路径写在单独的行上,还包括第一个文件的名称。

Eg the function should display below output for the above file/folder structure: 例如,对于上面的文件/文件夹结构,该功能应显示在下面的输出中:

T1.indd T1.indd

Links/Tree.png 链接/Tree.png

Links/Images/T1.jpg 链接/图片/T1.jpg

Docs/T1.docx Docs / T1.docx

The only thing that I can recommend to you is study the File class in Java. 我可以向您推荐的唯一一件事是研究Java中的File类。 This class contains all the methods you need for read,list the content of a folder and more utils methods. 此类包含读取所需的所有方法,列出文件夹的内容以及更多utils方法。

Here is the link, I hope that this can help you: https://docs.oracle.com/javase/7/docs/api/java/io/File.html 这是链接,希望对您有所帮助: https : //docs.oracle.com/javase/7/docs/api/java/io/File.html

If you want more help, please show your code. 如果您需要更多帮助,请显示您的代码。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM