package fengke.io; |
/** |
* new File(e:)和new File(d:)的结果不一样 |
* @author 锋客 |
* 解释: |
* getAbsolutePath |
* public String getAbsolutePath()返回抽象路径名的绝对路径名字符串。 |
* 如果此抽象路径名已经是绝对路径名,则返回该路径名字符串,这与 getPath() 方法一样。 |
* 如果此抽象路径名是空的抽象路径名,则返回当前用户目录的路径名字符串,该目录由系统属性 user.dir 指定。 |
* 否则,使用与系统有关的方式分析此路径名。 |
* 在 UNIX 系统上,通过根据当前用户目录分析某一相对路径名,可使该路径名成为绝对路径名。 |
* 在 Microsoft Windows 系统上,通过由路径名指定的当前驱动器目录(如果有)来分析某一相对路径名, |
* 可使该路径名成为绝对路径名;否则,可以根据当前用户目录来分析它。 |
*/ |
import java.io.File; |
public class FileDemo1 { |
|
public static void main(String[] args) { |
//.class文件放在e盘 |
File file = new File( "e" ); |
System.out.println(file.getAbsolutePath()); |
file = new File( "e:\\" ); |
System.out.println(file.getAbsolutePath()); |
file = new File( "e:" ); |
System.out.println(file.getAbsolutePath()); |
|
file = new File( "c:" ); |
System.out.println(file.getAbsolutePath()); |
|
file = new File( "c:\\" ); |
System.out.println(file.getAbsolutePath()); |
|
file = new File( "d:" ); |
System.out.println(file.getAbsolutePath()); |
|
file = new File( "d:\\" ); |
System.out.println(file.getAbsolutePath()); |
|
|
} |
|
} |