import java.io.File;
public class MainClass {
public static void main(String[] a) {
File myFile = new File("C:" + File.separator + "jdk1.5.0" + File.separator, "File.java");
System.out.println(myFile.getAbsoluteFile());
}
}
运行结果如下:
Returns the absolute path for the directory or file referenced by the current File object
import java.io.File;
public class MainClass {
public static void main(String[] a) {
File myFile = new File("C:" + File.separator + "jdk1.5.0" + File.separator, "File.java");
System.out.println(myFile.getAbsolutePath());
}
}
运行结果如下: