Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here



How can I read data from the net (http) by FredrikN
Posted: 18 Apr 03 (Edited 22 Apr 03)

So you want to read data from the net.

This is one easy way you can do it
It creates a socket and then read line by line until the end of the file.

import java.io.*;
import java.net.*;
public class Driver
    public static void main(String[] args) throws IOException
        URL site = new URL("http://www.thegate.nu/uptime.php";);
        URLConnection con = site.openConnection();
        BufferedReader data = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String d = data.readLine();
        while(d != null)
            d = data.readLine();

Back to Java FAQ Index
Back to Java Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close