Get the filePath from Filename using Java

后端 未结 5 916
日久生厌
日久生厌 2021-01-04 05:33

Is there a easy way to get the filePath provided I know the Filename?

5条回答
  •  别那么骄傲
    2021-01-04 06:20

    I'm not sure I understand you completely, but if you wish to get the absolute file path provided that you know the relative file name, you can always do this:

    System.out.println("File path: " + new File("Your file name").getAbsolutePath());
    

    The File class has several more methods you might find useful.

提交回复
热议问题