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


Stuff I use to make videos

Windows notebook – http://amzn.to/2zcXPyF

Apple MacBook Pro – http://amzn.to/2BTJBZ7

Desktop - http://amzn.to/2zct252

Microphone – http://amzn.to/2zcYbW1

notebook mouse – http://amzn.to/2BVs4Q3

Screen Recording Software – Camtasia