url.openStream()和url.openConnection().getInputStream()两者区别

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/15 20:27:10
url.openStream()和url.openConnection().getInputStream()两者区别url.openStream()和url.openConnection().getI

url.openStream()和url.openConnection().getInputStream()两者区别
url.openStream()和url.openConnection().getInputStream()两者区别

url.openStream()和url.openConnection().getInputStream()两者区别
两个是一样的.下面是url.openStream()的源码:
public final InputStream openStream() throws java.io.IOException {
return openConnection().getInputStream();
}
他也是先通过openConnection()方法获取URLConnection对象,然后调用getInputStream()方法.