Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help making URL.openStream work ?!?

6 views
Skip to first unread message

Michael Bonnell

unread,
Feb 25, 1999, 3:00:00 AM2/25/99
to
Hello, I'm asking for help because I'm really stuck - been stuck here
for days.
The following code is from the sun.java Tutorial. I downloaded the
jdk1.2
final edition a couple of months ago.

Why doesn't this work for me. It works for *other* people. How do I
pay my dues
so I can learn this stuff? Any help would be really appreciated!
I using win95, DUN, jdk1.2, kawa3.2 with 1.2 additional files.

-Michael

--------------------------------------
import java.net.*;
import java.io.*;

public class URLReader {
public static void main(String[] args) throws Exception {
URL yahoo = new URL("http://www.yahoo.com/");
BufferedReader in = new BufferedReader(
new InputStreamReader(
yahoo.openStream()));

String inputLine;

while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);

in.close();
}
}
--------------------------------------
D:\JDK1.2\bin\javac.exe URLReader.java
Class Path -
.;D:\bin\Kawa\kawaclasses.zip;d:\jdk1.2\lib\tools.jar;d:\jdk1.2\jre\lib\rt.jar

File Compiled...
No Errors...
--------------------------------------
JAVA EXE 24,064 12-01-98 3:37p java.exe
JAVAC EXE 25,600 12-01-98 3:37p javac.exe
RT JAR 10,478,246 12-01-98 3:37p rt.jar
--------------------------------------
It dies with the following exception stack dump:
D:\JDK1.2\bin\java.exe URLReader
Working Directory - D:\JAVA\Tutorial\networking\urls\example-1dot1\
Class Path -
.;D:\bin\Kawa\kawaclasses.zip;d:\jdk1.2\lib\tools.jar;d:\jdk1.2\jre\lib\rt.jar

java.net.SocketException: Descriptor not a socket: no further
information
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Compiled Code)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:125)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:112)
at java.net.Socket.<init>(Socket.java:269)
at java.net.Socket.<init>(Socket.java:98)
at sun.net.NetworkClient.doConnect(NetworkClient.java:54)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:320)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:409)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:260)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:270)
at sun.net.www.http.HttpClient.New(HttpClient.java:282)
at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:372)

at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Compiled
Code)
at java.net.URL.openStream(URL.java:818)
at URLReader.main(Compiled Code)
Exception in thread "main" Process Exit...
--------------------------------------
Oh if you know what's messed up Please tell me,
mailto:mbon...@onlink.net


mi...@west.net

unread,
Feb 26, 1999, 3:00:00 AM2/26/99
to
On Thu, 25 Feb 1999 15:59:04 -0500, Michael Bonnell
<mbon...@onlink.net> wrote:

Michael,

Try this...

URL myURL = new URL("http://www.yahoo.com/");
URLConnection myURLConn = myURL.openConnection();
myURLConn.connect();

InputStreamReader reader = new
InputStreamReader(myURLConn.getInputStream());

BufferedReader rbuf = new BufferedReader(reader);

String inputLine;

while ((inputLine = rbuf.readLine()) != null)
System.out.println(inputLine);

rbuf.close();
reader.close();

Ross

---

Michael Bonnell

unread,
Feb 26, 1999, 3:00:00 AM2/26/99
to mi...@west.net
Ross, thank you for responding.
I'm sure this works on almost every system except mine :-| Even this code crashes
with "Descriptor not a
Socket". I think it could be a WINDOWS problem. I use win95 on a not very fancy
486 with 16 meg
ram and a big swap file. My machine uses dial up networking to connect using ppp
over TCP/IP. I'm
using jdk1.2 final. Could I ask that some one else with a similar setup try this
code and tell me if it works
for you or not. It has to be a windows problem but it is *really* getting to me.
Given enough time a
problem should be solveable but its't a week enough!


> mi...@west.net wrote:
>
> > On Thu, 25 Feb 1999 15:59:04 -0500, Michael Bonnell
> > <mbon...@onlink.net> wrote:
> >
> > Michael,
> >
> > Try this...

> >[note I just added the wrapper for ease of use]<pre>

import java.io.*;
import java.net.*;

public class NetSuggest{


public static void main(String[] args) throws Exception {

URL myURL = new URL("http://www.yahoo.com/");
URLConnection myURLConn = myURL.openConnection();
myURLConn.connect();

InputStreamReader reader = new
InputStreamReader(myURLConn.getInputStream());

BufferedReader rbuf = new BufferedReader(reader);

String inputLine;

while ((inputLine = rbuf.readLine()) != null)
System.out.println(inputLine);

rbuf.close();
reader.close();
}
}
</pre>


> Ross
> ---
>
> >Hello, I'm asking for help because I'm really stuck - been stuck here for days.
>
> >The following code is from the sun.java Tutorial. I downloaded the jdk1.2
> >final edition a couple of months ago.
> >
> >Why doesn't this work for me. It works for *other* people. How do I pay my
> dues
> >so I can learn this stuff? Any help would be really appreciated!
> >I using win95, DUN, jdk1.2, kawa3.2 with 1.2 additional files.
> >
> >-Michael

> [snip diagnostic stuff]


0 new messages