我想弄清楚当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。
答案 0 :(得分:1)
因为HttpURLConnection本身就是抽象的,并且是由一个你还没见过的类来实现的,它确实覆盖了那个方法。