|
-
May 8th, 2002, 02:58 AM
#1
Thread Starter
Frenzied Member
Connecting to a webserver
I need to write a small java app which will navigate to a webpage and retrieve the default page
This sort of this is trivial in vb - using inet control, but how can I do it in java?
The app is to be invoked from a shell script and the only output will be using system.println.
Thanks
-
May 8th, 2002, 06:35 PM
#2
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();
}
}
-
May 9th, 2002, 02:42 AM
#3
Thread Starter
Frenzied Member
Thanks VirtuallyVB
I actually found that exact same code yesterday just as I was about go home and didn't get around to mentioning it in this thread.
http://java.sun.com/docs/books/tutor...eadingURL.html
Thanks again.
-
May 9th, 2002, 04:33 PM
#4
I wanted to give you the url for that example and also for the general tutorial page, but I only had the downloaded version handy.
Anyway, now that you found that tutorial, you have an excellent resource.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|