我所经历的java.net包和read this:URL如何写入一次?
URL是“写一次”的对象。一旦创建了URL对象, 就不能更改其任何属性(协议,主机名,文件名或端口号 )。
但是,如果我们看到的java.net.URL我们会发现这样的:
protected void set(String protocol, String host,
int port, String file, String ref)
和
protected void set(String protocol, String host, int port,
String authority, String userInfo, String path,
String query, String ref)
所以,我知道这些都是保护方法,但这些可以通过访问
public static void setURLStreamHandlerFactory(URLStreamHandlerFactory fac)
所以,我的问题是,如果我在上面引用的声明含糊不清或者我误解了它?
请提供一个链接到你的报价“URL是写一次......”。所以我们可以更好地理解上下文 – CocoNess 2014-11-06 07:47:09
看看这个最底部: http://docs.oracle.com/javase/tutorial/networking/urls/creatingUrls.html – dosdebug 2014-11-06 07:48:26
问题可能是更好的问:“是吗?适合使用一个人为的'URLStreamHandler'来改变那些不可改变的字段?“除非你本着'URLStreamHandler'的精神来做事,否则答案可能不是。 – 2014-11-06 07:53:47