1. Introduction
The toString() method returns the pathname string of the given File object. This method is equivalent to using Java IO getPath) method.
2. Method signature
Parameters:
- method does not take any parameter
Returns
- true - if file or directory exists in the filesystem
Throws
- SecurityException - when we do not have access to the file or directory
3. Examples
3.1. Example code that prints the results of toString
method on several File
objects
The output:
4. Conclusion
In this article, we presented toString
method used for printing the full path of the given File
object. This method is returns the same result as getPath()
method.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}