CHPP Development/Java/Login examples

From Hattrick
Revision as of 16:24, 17 February 2006 by Filipx (talk | contribs)
Jump to navigationJump to search

Step1: Getting the recommended server


public boolean getRecommendedServer() {
  try {
     URL url = new URL("http://www.hattrick.org/Common/menu.asp?outputType=XML");
     URLConnection connection = url.openConnection();
     BufferedReader br = new BufferedReader(
              new InputStreamReader(connection.getInputStream()));
     String line = "";
     while ((line = br.readLine()) != null) {
        //do something with the line
        //maybe write it into a file
     }
  } catch (Exception e) {
     e.printStackTrace();
     return false;
  }
  return true;
}