我正在使用Java尝试仅通过其名称检索位于C驱动器上的文件路径。例如,如果我有" test.txt"在我的桌面上它将返回C://Users/LukesComputers/Desktop/test.txt。代码看起来像这样:
public String getPathByName(String fileName) { //Assume fileName equals text.txt and is located on the desktop
String path = //Calls something to get the path
return path;
}