Getting Information from a Remote Site 

  • So once you have a connection to a web server it is likely that the first thing you will want to do is get data. Getting data from a web server is as easy as opening a connection and uses a data stream to handle the flow of data between your application and the server. 
  • Typically, you will read in a data file from a given URL using something like the following: 
  • try
      {
      Socket s = new Socket("www.extropia.com", 
                             80);
      DataInputStream d = new DataInputStream
                          (s.getInputStream());
      String line = d.readLine();
      System.out.println("line: " + line);
      
      System.out.println("" + url.openStream());
      }
    catch (IOException e)
      {
      System.out.println("Error: " + e);
      }

Additional Resources:

Connecting to a Server 
Table of Contents
Sending Information to a Remote Site 


Graphics & Media Lab. >> Библиотека | Курсы | Графикон

Hosted by Graphics & Media Lab
http://graphics.cs.msu.su
lab_logo
mailto: Laboratory