You need to move "in.close()" out of the while loop. As the code stands, you are 
closing the
input stream after reading the first line.

Joan

> x-MEL: melsud.res.ray.com <M.E.L Raytheon Systems Company>
> X-Originating-IP: [212.20.228.118]
> Mime-Version: 1.0
> Date: Wed, 12 Jan 2000 15:02:35 GMT
> From: Yang XIAO <[EMAIL PROTECTED]>
> Subject: Re: [SERVLET] telnet similar method
> To: [EMAIL PROTECTED]
>
> Hi, Craig
>
> thanks for the reply. I excuted URLReader class:
>
> import java.io.*;
> import java.net.*;
>
> public class URLReader {
>         public static void main(String[] args) throws Exception {
>                 URL php = new URL("http://www.php.net/");
>                 BufferedReader in = new BufferedReader(
>                                         new InputStreamReader(
>                                                 php.openStream()));
>                 String inputLine;
>
>                 while((inputLine = in.readLine()) != null) {
>                         System.out.println(inputLine);
>                         in.close();
>                 }
>         }
> }
>
> but I got
> <HTML>
> java.io.IOException: Stream closed
>         at java.io.BufferedReader.readLine(BufferedReader.java)
>         at URLReader.main(URLReader.java:14)
>
> Can you please tell me why?
>
> sorry it's out of question. But really appreciate your instruction.
> Stella
>
>
> > > Hi, there
> > >
> > > I'm developing a servlet to get data from a web server. Please does
> >anyone
> > > know a method which can simulate the following command:
> > >
> > > telnet server:port
> > > GET https://requestmessage
> > >
> >
> >See the class java.net.URLConnection.  There's some good examples of using
> >this
> >in the Java Language Tutorial at (http://java.sun.com/docs/books/tutorial)
> >--
> >see the Networking trail.
> >
> > >
> > > thanks in advance
> > > Stella
> > >
> >
> >Craig McClanahan
> >
> >___________________________________________________________________________
> >To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> >of the message "signoff SERVLET-INTEREST".
> >
> >Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >Resources: http://java.sun.com/products/servlet/external-resources.html
> >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to