在本地文件系统中二者的使用有什么区别?
解决方案 »
- 从“双重检查成例”引出的一个关于线程安全的疑惑
- 关于Collator的中文排序问题(bug?)
- 为什么在命令窗口能运行在ECLIPSE不能运行
- 北京的那个JAVA培训机构比较好,一般得多少钱?
- 怎样在jsp/java中调用微软的ActiveX?
- 如何设置某一个Cell的CellEditor?
- 怎样设置JFileChooser只能选路径?
- 各位高手,在java程序中我想用properties文件,请问怎么在java程序中怎么调用,多谢赐教
- ◎◎#请教各位大哥:怎样存储邮件内容content为Object类型到SQL Server
- 光标定位偏移
- 关于连接数据库的两个问题:)我是菜,谢谢指教!
- 高手,小妹初学java,给我推荐一本比较好的教材吧!
A URI is a uniform resource identifier while a URL is a uniform resource locator. Hence every URL is a URI, abstractly speaking, but not every URI is a URL. This is because there is another subcategory of URIs, uniform resource names (URNs), which name resources but do not specify how to locate them. The mailto, news, and isbn URIs shown above are examples of URNs.
The conceptual distinction between URIs and URLs is reflected in the differences between this class and the URL class. An instance of this class represents a URI reference in the syntactic sense defined by RFC 2396. A URI may be either absolute or relative. A URI string is parsed according to the generic syntax without regard to the scheme, if any, that it specifies. No lookup of the host, if any, is performed, and no scheme-dependent stream handler is constructed. Equality, hashing, and comparison are defined strictly in terms of the character content of the instance. In other words, a URI instance is little more than a structured string that supports the syntactic, scheme-independent operations of comparison, normalization, resolution, and relativization. An instance of the URL class, by contrast, represents the syntactic components of a URL together with some of the information required to access the resource that it describes. A URL must be absolute, that is, it must always specify a scheme. A URL string is parsed according to its scheme. A stream handler is always established for a URL, and in fact it is impossible to create a URL instance for a scheme for which no handler is available. Equality and hashing depend upon both the scheme and the Internet address of the host, if any; comparison is not defined. In other words, a URL is a structured string that supports the syntactic operation of resolution as well as the network I/O operations of looking up the host and opening a connection to the specified resource.
URI:Universal Resource Identifier
可以看出URL是URI的一种
URL是统一资源定位符,URI是统一资源标识符。至于你在本地使用的时间,没有什么大的差别的,需要使用URL的时间你不能使用URI,反之亦然。
· URI 类只关心资源的标识和对URI的解析.它没有方法来检索它的URI所标识的资源。
· URI 类与URL 类相比,它更能适应相关的规范。
· 一个URI 对象能表示一个相对URI 。URL 类在存放之前,就已经对所有的URI进行了“绝对化”的处理。简而言之,一个URL 对象就是网络应用层协议进行网络检索的一个代理,而一个URI 对象就只纯粹地做string的解析和操作的工作。URI 类没有进行网络检索的能力。URL 类有一些进行string解析的方法。比如getFile( ) 和 getRef( ) 方法,但很多都是蹩脚的方法,总是不完全像有关的规范上所说的那样好用。假如你现在用的是java1.4版本或更新的版本,这时你就可以做出选择,如果你想下载一个URL指示的内容时,你应该使用 URL类;如果你想使用URI类来进行标识的工作而不是用来检索的时候,你应该用URI类。例如,去标识一个XML namespace 的URI。在一些情况下,当你同时需要实现这两种功能时,你可以用方法toURL( ) 把一个URI 转换成一个 URL 。在java1.5中,你还能用类URL 中的方法toURI( ) 把一个URL 转换成一个URI 。更具体的去这里,你想要了解的问题这里都讲了http://www.matrix.org.cn/resource/article/44/44187_URLEncoder+URLDecoder.html