getCanonicalpath函数的简单学习
来源:互联网 发布:福建网络干部培训学院 编辑:程序博客网 时间:2024/06/07 01:17
今天学习newsgroup文档预处理的java实现时,遇到了getCanonicalpath()函数,之前没接触过,所以查了下资料,整理如下。
getCononicalPath()是获取文档路径的一个函数,与常用的getPath(),getAbsolutePath()有所区别。
1. getPath()得到的文件构造时参数中给出的路径。
例如:
File file = new File(".\\test.txt");
System.out.println(file.getPath());
输出的路径为 .\test.txt。
File file = new File("E:\\workspace\\java\\test.txt");
System.out.println(file.getPath());
输出的路径为 E:\\workspace\\java\\test.txt。
2. getAbsolutePath()返回的是文件的绝地路径。
例如:
File file = new File(".\\test.txt");
System.out.println(file.getAbsolutePath());
输出的路径为 E:\workspace\java\\est.txt。
File file = new File("E:\\workspace\\java\\test.txt");
System.out.println(file.getAbsolutePath());
输出的路径为 E:\workspace\java\test.txt。
3. getCanonicalPath()也是返回文件的绝对路径,但会去除[..]这样的符号,即返回的是标准的绝地路径。
例如:
File file = new File("..\\java\\test.txt");
System.out.println(file.getAbsolutePath());
System.out.println(file.getCanonicalPath());
getAbsolutePath()输出的路径为 E:\workspace\..\java\test.txt。
getCanonicalPath()输出的路径为 E:\workspace\java\test.txt。
- getCanonicalpath函数的简单学习
- Javascript函数的简单学习
- getPath getAbsolutePath和getCanonicalPath的不同
- getPath getAbsolutePath和getCanonicalPath的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- java里getPath、 getAbsolutePath、getCanonicalPath的区别
- java里getPath、 getAbsolutePath、getCanonicalPath的区别
- File的getPath(),getAbsolutePath(),getCanonicalPath()区别
- getPath getAbsolutePath和getCanonicalPath的区别
- getPath(), getAbsolutePath()和 getCanonicalPath() 的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- java里getPath、 getAbsolutePath、getCanonicalPath的区别
- java里getPath、 getAbsolutePath、getCanonicalPath的区别
- java里getPath、 getAbsolutePath、getCanonicalPath的区别
- File类的getPath()、getAbsolutePath()、getCanonicalPath()
- LR中简单的函数学习
- FilePath类的getPath(),getAbsolutePath(),getCanonicalPath的区别
- 在Yii框架下用递归方式简单实现无限极分类
- Mysql一些变态的sql写法
- @ModelAttribute
- Hive入门指南
- WPF中画虚线
- getCanonicalpath函数的简单学习
- 新唐N32926调试--wifi模块调试
- LeetCode_OJ【18】4Sum
- 正则表达式-图片链接
- sql 循环处理查询到的结果集
- android设备的适配
- The project cannot be built until build path errors are resolved错误。
- Leetcode Algorithm No.260 Single Number III
- request的setAttribute()怎么用的?