这个问题, 不了解一下还是挺恍惚它们之间的区别的.

其实也挺简单的.

getPath()-->>new File()时的路径

getAbsolutePath()-->>当前路径+new File()时的路径

getCanonicalPath()-->>规范路径真正意义的绝对路径

这里面的文章主要还是只new File()的时候加入了"."和".."如何用了这2个. getAbsolutePath()就是如上面解释的一样.而getCanonicalPath()会把"."和".."翻译过来.

就是这么简单.

关于File.getPath,File.getAbsolutePath,File.getCanonicalPath的区别的更多相关文章

  1. File 类的 getPath()、getAbsolutePath()、getCanonicalPath() 的区别【转】

    File 类的 getPath().getAbsolutePath().getCanonicalPath() 的区别 感谢大佬:https://blog.csdn.net/zsensei/articl ...

  2. java里getPath、 getAbsolutePath、getCanonicalPath的区别

    本文链接:https://blog.csdn.net/wh_19910525/article/details/9314675 File的这三个方法在api中都有说明,仅以程序为例说明. package ...

  3. file的getPath getAbsolutePath和getCanonicalPath的区别

    转自:http://www.blogjava.net/dreamstone/archive/2007/08/08/134968.html file的这几个取得path的方法各有不同,下边说说详细的区别 ...

  4. File的getPath()和getAbsolutePath()和getCanonicalPath()的差别

    这几个方法是有一次无意的发现,我当时也不知道什么意思,就百度了,查到了一些列子: 原文地址http://www.blogjava.net/dreamstone/archive/2007/08/08/1 ...

  5. file的getPath getAbsolutePath和getCanonicalPath的不同

    file的这几个取得path的方法各有不同,下边说说详细的区别 概念上的区别:(内容来自jdk,个人感觉这个描述信息,只能让明白的人明白,不明白的人看起来还是有点难度(特别试中文版,英文版稍好些)所以 ...

  6. file.getPath() getAbsolutePath() getCanonicalPath()区别

    package file; import java.io.File; import java.io.IOException; public class getFilePath { public sta ...

  7. Visual Studio发布Web项目报错:Unable to add 'xxx' to the Web site. Unable to add file 'xxx'. The specified file could not be encrypted.

    背景 Visual Studio下的Web项目 现象 发布时遇到Unable to add 'xxx' to the Web site.  Unable to add file 'xxx'. The ...

  8. 配置tomcat连接器后,启动服务报错“No Certificate file specified or invalid file format"异常

    1:原来的配置是 <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true&quo ...

  9. 配置CAS错误No Certificate file specified or invalid file format

    配置tomcat证书 keystore文件后启动一直报错:(tomcat版本:apache-tomcat-6.0.43) tomcat配置: <Connector port="8443 ...

  10. ShopEx访问提示Incompatible file format: The encoded file has format major ID 2, whereas the Loader expects 4

    今天测试了下ShopEx程序,但是ShopEx安装时(程序放在public_html目录下的test目录中)遇到了问题,提示错误如下:Fatal error: Incompatible file fo ...

随机推荐

  1. 约瑟夫环是一个数学的应用问题:已知n个人(以编号1,2,3...n分别表示)围坐在一张圆桌周围。从编号为k的人开始报数,数到m的那个人出列;他的下一个人又从1开始报数,数到m的那个人又出列;依此规律重复下去,直到圆桌周围的人全部出列。

    以数组的方法: public static void main(String[] args) {        final int n = 10;          final int k = 1;  ...

  2. .net,mvc使用bootstrap做一个标准后台

    今天准备搭一个公用后台,使用bootstrap,方便今后开发,顺便mark一下 后期列表页将使用kendo-ui,增强后台的效果 下面是代码... login页面 @{ Layout = null; ...

  3. Programming Impala Applications

    Programming Impala Applications The core development language with Impala is SQL. You can also use J ...

  4. 使用Ant发布hadoop代码到服务器

    首先,搭建Ant环境: 1.1.下载antzip包,可以直接从官网下,也可以从我的csdn账号下载,这里我使用的Ant版本是:apache-ant-1.8.4-bin CSDN Ant 所需jar包下 ...

  5. NetAddr

    http://www.searchdatabase.com.cn/showcontent_66349.htm   [techTarget中国,其专注于IT领域企业级高端市场,为IT专业技术人员和管理决 ...

  6. html5+css3中的background: -moz-linear-gradient 用法

    在CSS中background: -moz-linear-gradient 让网站背景渐变的属性,目前火狐3.6以上版本和google浏览器支持这个属性. background: -moz-linea ...

  7. Struts2的运行流程以及关键拦截器介绍

    Struts2的运行流程 1.ActionProxy是Action的一个代理类,也就是说Action的调用是通过ActionProxy实现的,其实就是调用了ActionProxy.execute()方 ...

  8. 嵌入式LINUX入门到实践(二)

    这篇中将围绕韦东山LINUX第二部分教程源码,对IIC协议进行程序实现上的分析. /* I2C registers */#define IICCON      (*(volatile unsigned ...

  9. 微软企业库5.0学习-Security.Cryptography模块

    一.微软企业库加密应用模块提供了两种加密: 1.Hash providers :离散加密,即数据加密后无法解密 2.Symmetric Cryptography Providers:密钥(对称)加密法 ...

  10. substr函数

    substr(字符串,截取开始位置,截取长度) //返回截取的字 substr('Hello World',0,1) //返回结果为 'H'  *从字符串第一个字符开始截取长度为1的字符串 subst ...