toString(): This method is available in the java.io.File class of Java.
Syntax:
String java.io.File.toString()
This method returns the pathname string of this abstract pathname. This is just the string returned by the getPath method.
Parameters: NA
Returns: The string form of this abstract pathname.
Exceptions: NA
Approach
Java
import java.io.File;public class FiletoString {public static void main(String[] args) {String pathname = "D:\\hello.txt";File file = new File(pathname);System.out.println(file.toString());}}
Output:
D:\hello.txt
No comments:
Post a Comment