Read a Remote File via HTTP
void getToDoList () { 
 
  try {
 
    URL                url;
    URLConnection      urlConn;
    DataInputStream    dis;
 
    url = new URL("http://webserver.our-intranet.com/ToDoList/ToDoList.txt");
 
    // Note:  a more portable URL:
    //url = new URL(getCodeBase().toString() + "/ToDoList/ToDoList.txt");
 
    urlConn = url.openConnection();
    urlConn.setDoInput(true);
    urlConn.setUseCaches(false);
 
    dis = new DataInputStream(urlConn.getInputStream());
    String s;
 
    toDoList.clear();
 
    while ((s = dis.readLine()) != null) {
      toDoList.addItem(s);
    }
    dis.close();
    }
    catch (MalformedURLException mue) {}
    catch (IOException ioe) {}
  }
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License