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.

OUTPUT :

FileName.java
C:\jdk\FileName.java

Reference:
https://docs.oracle.com/javase/7/docs/api/java/io/File.html


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com