🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Socket.getInputStream() question

#275
From: Ron
Date: Thu, 25 Mar 2004 14:09
31 lines
2260 bytes
Thanks for the help, but I am still a little confused. The fragment I wrote
just imports java.io.* and java.net.* not
org.apache.commons.net.io.SocketInputStream; so, if Socket does return a
SocketInputStream, where does it get it from? The Java documentation just
says
public InputStream getInputStream()
                           throws IOExceptionReturns an input stream for
this socket.
so, where does the SocketInputStream come from?

Thanks.

RON
"Shankar Unni" <shankarunni@netscape.net> wrote in message
news:40620071$1@newsgroups.borland.com...
> 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: <4062e7ff$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4061e5c3$1@newsgroups.borland.com> <40620071$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-25 06:10:21 PST
Reply-To: "Ron" <rgans@nospamRonaldgansphotographyDOTcom>
From: "Ron" <rgans@nospamRonaldgansphotographyDOTcom>
Newsgroups: borland.public.jbuilder.java.api
References: <4061e5c3$1@newsgroups.borland.com> <40620071$1@newsgroups.borland.com>
Subject: Re: Socket.getInputStream() question
Date: Thu, 25 Mar 2004 09:09:04 -0500
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 161.233.9.45
Message-ID: <4062e7ff$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1080223743 161.233.9.45 (25 Mar 2004 06:09:03 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail