为什么在Dalvik的HttpURLConnection中不会覆盖getInputStream()?

时间:2014-04-18 08:25:41

标签: java android dalvik

我想弄清楚当getInputStream触发connect方法时,但是这个HttpUrlConnection类不会覆盖getInputStream。这个怎么运作?我没有看到任何其他线索

〜ANDROID_HOME /来源/机器人-19 /爪哇/净/ URLConnection的#的getInputStream

 /**
 * Returns an {@code InputStream} for reading data from the resource pointed by
 * this {@code URLConnection}. It throws an UnknownServiceException by
 * default. This method must be overridden by its subclasses.
 *
 * @return the InputStream to read data from.
 * @throws IOException
 *             if no InputStream could be created.
 */
public InputStream getInputStream() throws IOException {
    throw new UnknownServiceException("Does not support writing to the input stream");
}

但在~ANDROID_HOME / sources / android-19 / java / net / HttpURLConnection.java中,不会覆盖getInputStream。

https://android.googlesource.com/platform/libcore/+/android-4.4.2_r2/luni/src/main/java/java/net/HttpURLConnection.java enter image description here

1 个答案:

答案 0 :(得分:1)

因为HttpURLConnection本身就是抽象的,并且是由一个你还没见过的类来实现的,它确实覆盖了那个方法。

相关问题