The getName() method returns the name of the file or directory. Note that this method returns only the last name in the pathname sequence.
2. Method signature
Parameters:
method does not take any parameter
Returns
String - the name of the file or directory
3. Examples
3.1. The program that prints the file and directory name using getName() method
The output:
4. Conclusion
In this short article, we presented how to use File.getName() method in a single example. This method returns the simple name of the file or directory pointed by the File object.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}