URL的getFile()和getPath()方法的区别
来源:互联网 发布:中国象棋开局软件 编辑:程序博客网 时间:2024/06/11 23:36
import java.net.MalformedURLException;import java.net.URL;public class dd {/** * @param args */public static void main(String[] args) {try {URL url = new URL("file://ftp.yoyodyne.com/pub/files/foobar.txt?id=123456");System.out.println("url.getFile()="+url.getFile());System.out.println("url.getPath()="+url.getPath());} catch (MalformedURLException e) {e.printStackTrace();}}}
返回的结果:
url.getFile()=/pub/files/foobar.txt?id=123456
url.getPath()=/pub/files/foobar.txt
当将上面的
file://ftp.yoyodyne.com/pub/files/foobar.txt?id=123456改成
file://ftp.yoyodyne.com/pub/files/foobar.txt时:
返回的结果:
url.getFile()=/pub/files/foobar.txt
url.getPath()=/pub/files/foobar.txt
java docs文档上说的:
The URL.getFile()
javadocs say this:
Gets the file name of this URL. The returned file portion will be the same as getPath(), plus the concatenation of the value of getQuery(), if any. If there is no query portion, this method and getPath() will return identical results.
They will be the same unless there is a query string, e.g. a ?somename=value&somethingelse=value2
in the URL.
- URL的getFile()和getPath()方法的区别
- URL的getFile()和getPath()方法的区别
- File和URL的getPath()方法区别
- URL的getFile()方法的乱码问题
- file中getPath()和getAbsolutePath()和getCanonicalPath()方法的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- getPath(), getAbsolutePath()和 getCanonicalPath() 的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- class.getResource()和URL的getPath()分别作了什么
- java.io.File 中 getPath(), getAbsolutePath() 和 getCanonicalPath() 三个方法的区别
- java.io.File 中 getPath(), getAbsolutePath() 和 getCanonicalPath() 三个方法的区别
- java.io.File 中 getPath(), getAbsolutePath() 和 getCanonicalPath() 三个方法的区别
- java.io.File 中 getPath(), getAbsolutePath() 和 getCanonicalPath() 三个方法的区别
- File的getPath()和getAbsolutePath()和getCanonicalPath()的区别
- getPath()与getAbsolutePath()的区别
- 使用struts2进行国际化
- Determining and Monitoring the Connectivity StatusAndroid 电源管理专题之获取和监测网络连接状态
- Linux 核心之硬件基础
- 关于For循环中定义的变量在循环外的引用
- ASP.NET文本编辑器(FCKeditor)详细介绍
- URL的getFile()和getPath()方法的区别
- 基于cocos2d-x引擎的游戏框架设计
- ASP.NET配置文件有那些秘密? (转)
- [转]Delphi 几个读写注册表的函数
- Python tuple 元组详解
- image 缩放
- 判断文件夹是否存在,不存在则创建文件夹
- linu核心之软件基础
- 在frameset,frame,iframe中如何操作其他框架中的页面以及如何刷新框架中的页面