Java I/O – Get file name and file path

In Java File class a member method getName() returns the name of the file or directory denoted by this abstract path name, or the empty string if this path-name’s name sequence is empty

and getPath() method returns the path of a file.

Lets take an example to understand the two methods in a better way. In this example we will construct the file path using File constructor.



Partner Sites