File GetPath() Example
Converts this abstract pathname into a pathname string
File class GetPath() method example. This example shows you how to use GetPath method.This method Converts this abstract pathname into a pathname string
Here is the code:-
/**
* @Program that Converts this abstract pathname into a pathname string.
* GetPath.java
* Author:-RoseIndia Team
* Date:-30-May-2008
*/
import java.io.*;
public class GetPath {
public static void main(String[] args)throws IOException {
File f = new File("/home/girish/Desktop/g.txt");
if (f.exists()) {
String s=f.getPath();
System.out.println("pathname into a pathname string is : " + s);
} else {
System.out.println("File does not exists");
}
}
} |
Output of the Program
| pathname into a pathname string is : /home/girish/Desktop/g.txt |
|