我有一个文件指向基本目录:
File baseDir = new File("c:\\baseDir");
现在我想“进入子目录”:
File subDir = new File("c:\\baseDir\\subDir");
我只找到了如何通过字符串连接来做到这一点。但是有 API 函数可以完成这项工作吗?
最佳答案
有一个重载构造函数可以达到此目的:
> File(File parent, String child)
Creates a new File instance from a parent abstract pathname and a child pathname string.
关于Java IO API : how to get into file subdirectory?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38036471/