2

According to the docs, it returns an InputStream. But also according to the docs, InputStream is an abstract class. So which particular subclass does .openStream() return?

2
  • 7
    The point of encapsulation is that you don't know or care. Commented Dec 26, 2013 at 20:16
  • 2
    Also, you can simply do .getClass() on the stream returned to find out. Commented Dec 26, 2013 at 20:16

1 Answer 1

3

The point of encapsulation is that you don't know or care.
You just use it as an InputStream, and whatever it returns will behave as you expect.
It could even return a different class on Sundays if it wanted to, and you still wouldn't know or care.

Reading the source, it looks like HTTP URLs return an instance of an internal class called HttpInputStream.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.