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
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
---
> 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]