File ToString() Example
Returns the pathname string of this abstract pathname.
File class ToString() method example. This example shows you how to use ToString method.This method Returns the pathname string of this abstract pathname.
Here is the code:-
/**
* @Program that Returns the pathname string of this abstract pathname.
* ToString.java
* Author:-RoseIndia Team
* Date:-31-May-2008
*/
import java.io.*;
public class ToString {
public static void main(String[] args) {
File f = new File("/home/girish/Desktop/girish.txt");
if (f.exists()) {
String s=f.toString();
System.out.println("String representation of path is : "+s);
} else {
System.out.println("File cannot exists: ");
}
}
} |
Output of the Program
| String representation of path is : /home/girish/Desktop/girish |
|