Get the filePath from Filename using Java
问题 Is there a easy way to get the filePath provided I know the Filename? 回答1: You can use the Path api: Path p = Paths.get(yourFileNameUri); Path folder = p.getParent(); 回答2: Look at the methods in the java.io.File class: File file = new File("yourfileName"); String path = file.getAbsolutePath(); 回答3: 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