Get a String representation of the current File object in Java
Description
The following code shows how to get a String representation of the current File object.
The string that is returned is the same as that returned by the getPath() method.
Example
/*from www . ja v a2 s.c om*/
import java.io.File;
public class Main {
public static void main(String[] a) {
File myFile = new File("C:" + File.separator + "jdk1.5.0" + File.separator, "File.java");
System.out.println(myFile.getParentFile());
System.out.println(myFile);
}
}
The code above generates the following result.