file.getPath() getAbsolutePath() getCanonicalPath()区别
来源:互联网 发布:古典舞演出服淘宝网 编辑:程序博客网 时间:2024/06/06 13:23
package file;import java.io.File;import java.io.IOException;public class getFilePath { public static void main(String[] args) throws IOException { System.out.println("------默认相对路径,取得路径不同-----"); File f = new File("..\\src\\file"); System.out.println(f.getPath()); System.out.println(f.getAbsolutePath()); System.out.println(f.getCanonicalPath()); System.out.println("------默认相对路径,取得路径不同-----"); File f2 = new File(".\\src\\file"); System.out.println(f2.getPath()); System.out.println(f2.getAbsolutePath()); System.out.println(f2.getCanonicalPath()); System.out.println("------默认绝对路径,取得路径相同-----"); File f3 = new File("C:\\src\\file"); System.out.println(f3.getPath()); System.out.println(f3.getAbsolutePath()); System.out.println(f3.getCanonicalPath());// 执行结果为:// ------默认相对路径,取得路径不同-----// ..\src\file// C:\workspace\Tip\..\src\file// C:\workspace\src\file// ------默认相对路径,取得路径不同-----// .\src\file// C:\workspace\Tip\.\src\file// C:\workspace\Tip\src\file// ------默认绝对路径,取得路径相同-----// C:\src\file// C:\src\file// C:\src\file// // 比较可以得到// getPath()返回的是构造方法里的路径,构造方法给的string是什么就是什么不做任何处理// getAbsolutePath()返回的是 user.dir+getPath(),也就是工程路径加上构造方法中的路径// getCanonicalPath()返回的是将符号完全解析的路径,也就是全路径。会进行上级目录计算。 }}
0 0
- file.getPath() getAbsolutePath() getCanonicalPath()区别
- file.getPath() getAbsolutePath() getCanonicalPath()区别
- file.getPath() getAbsolutePath() getCanonicalPath()区别
- 【java】File,file.getPath(), getAbsolutePath(), getCanonicalPath()区别
- File:getPath()&getAbsolutePath()&getCanonicalPath()
- File的getPath(),getAbsolutePath(),getCanonicalPath()区别
- getPath(),getAbsolutePath(),getCanonicalPath()区别
- Java getPath() getAbsolutePath() getCanonicalPath()区别
- Java中file类getPath(),getAbsolutePath(),getCanonicalPath()方法区别
- Java中file类getPath(),getAbsolutePath(),getCanonicalPath()方法区别
- java中File类的getPath(),getAbsolutePath(),getCanonicalPath()区别
- File的getPath()和getAbsolutePath()和getCanonicalPath()的区别
- Java中file类getPath(),getAbsolutePath(),getCanonicalPath()方法区别
- file中getPath()和getAbsolutePath()和getCanonicalPath()方法的区别
- file类中getPath()、getAbsolutePath()、getCanonicalPath()的区别
- java中File类的getPath(),getAbsolutePath(),getCanonicalPath()区别
- java中File类的getPath(),getAbsolutePath(),getCanonicalPath()区别
- java中File类的getPath(),getAbsolutePath(),getCanonicalPath()区别
- javaweb_js的dom节点操作应用
- 一个由于python程序fork子进程时复制对象导致的程序锁死的问题
- php实现文件下载
- <1>sizeof()的实现
- Java中的五种单例模式实现方法
- file.getPath() getAbsolutePath() getCanonicalPath()区别
- 学习PrintWriter类
- HAO WAN DE WANG ZHAN
- 移动创业者,这么多免费资源,你不要?
- Linux中页面的定期换出
- 设计模式—命令模式
- [机器学习笔记] Note1--机器学习简介
- Java WebService 简单实例
- 关于Nginx session sticky