getPath(): This method is available in the java.io.File class of Java.
Syntax:
String java.io.File.getPath()
This method converts this abstract pathname into a pathname string.
The resulting string uses the default name-separator character to separate the names in the name sequence.
Parameters: NA
Returns: The string form of this abstract pathname.
Exceptions: NA
Approach
Java
import java.io.File;public class FilegetPath {public static void main(String[] args) {String pathname = "D:\\hello.txt";File file = new File(pathname);System.out.println(file.getPath());}}
Output:
D:\hello.txt
No comments:
Post a Comment