在本地文件系统中二者的使用有什么区别?

解决方案 »

  1.   

    URIs, URLs, and URNs 
    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. 
      

  2.   

    URL:Universal Resource Location
    URI:Universal Resource Identifier
    可以看出URL是URI的一种
      

  3.   

    看来不讲清楚是不行了,其实URL和URI都属于JAVA.NET下面的一个类。
    URL是统一资源定位符,URI是统一资源标识符。至于你在本地使用的时间,没有什么大的差别的,需要使用URL的时间你不能使用URI,反之亦然。
      

  4.   

    URI是URL的一个抽象,它不仅包括了统一资源定位符(URL),还包括了统一资源名(URN).大多数实际应用中使用的URI都是URL,但是许多规范和标准像XML都是用URI来定义的.在java1.4和更新的版本中, URI被java.net.URI 类所表示.这个类与java.net.URL 相比有如下3点重要的区别:
    ·        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