通过名称获取文件路径

时间:2014-10-05 14:37:34

标签: java file

我正在使用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;
}

0 个答案:

没有答案