URL中openConnection的实现,该怎么解决
URL中openConnection的实现
public URLConnection openConnection() throws java.io.IOException {
return handler.openConnection(this);
}
以上是类URL中openConnection的代码。
handler是一个抽象类URLStreamHandler的变量。
从jdk API文档来看URLStreamHandler是没有子类的。
那是如何创建URLStreamHandler对象的呢?
抽象类应该不能new对象的吧。
------解决方案--------------------
URLStreamHandlerFactory
public URLConnection openConnection() throws java.io.IOException {
return handler.openConnection(this);
}
以上是类URL中openConnection的代码。
handler是一个抽象类URLStreamHandler的变量。
从jdk API文档来看URLStreamHandler是没有子类的。
那是如何创建URLStreamHandler对象的呢?
抽象类应该不能new对象的吧。
------解决方案--------------------
URLStreamHandlerFactory