Java Java File.getPath()
方法具有以下语法。
public String getPath()
示例
在下面的代码显示如何使用File.getPath()
方法。
import java.io.File;
public class Main {
public static void main(String[] args) throws Exception {
// create new files
File f = new File("c:/asdf/");
System.out.print(f.getPath());
}
}
执行上面代码,得到以下结果 -
c:\asdf