Results 1 to 4 of 4

Thread: Connecting to a webserver

  1. #1

    Thread Starter
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

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

  2. #2
    VirtuallyVB
    Guest

    Thumbs up

    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();
    }
    }

  3. #3

    Thread Starter
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    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.
    Mark
    -------------------

  4. #4
    VirtuallyVB
    Guest
    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
  •  



Click Here to Expand Forum to Full Width