🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #271

Re: Socket.getInputStream() question

#271
From: Shankar Unni
Date: Wed, 24 Mar 2004 21:41
16 lines
1663 bytes
Ron wrote:

> InputStream in = sock.getInputStream();
> in.read(....);
> 
> what I don't understand (as a novice) is: InputStream is abstract so it
> cannot be instantiated. But an InputStream object is being instantiated,
> right? So, how?

No, it's not being *directly* instantiated. What's being instantiated is 
a concrete subclass of InputStream (namely a SocketInputStream).

The reason the API is defined in this fashion (as returning the abstract 
base class) is to give the implementor some flexibility in returning a 
different type of InputStream in a different version, without forcing 
all the callers to recompile.
Technical Details
Message-ID: <40620071$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4061e5c3$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,6e32650011d9be01
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2004-03-24 13:50:24 PST
Date: Wed, 24 Mar 2004 13:41:06 -0800
From: Shankar Unni <shankarunni@netscape.net>
User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.api
Subject: Re: Socket.getInputStream() question
References: <4061e5c3$1@newsgroups.borland.com>
In-Reply-To: <4061e5c3$1@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 68.124.18.110
Message-ID: <40620071$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1080164465 68.124.18.110 (24 Mar 2004 13:41:05 -0800)
Lines: 16
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail