Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package maintenance;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLConnection;
- /**
- *
- * @author Tim
- */
- public class Checker {
- /**
- *
- * @return boolean returns a the status. First of Gamesig online or not. Then s4, then LOCO
- * Will read the data from the GameSig maintenance checker
- */
- public boolean[] checkGames() {
- String line = null; // create empty string
- boolean[] array = new boolean[3]; //create array
- //Set gamesig on online and the rest on offline
- array[0] = true;
- array[1] = false;
- array[2] = false;
- try {
- URLConnection urlConn = null; //create connection object
- InputStreamReader inStream = null; //create inputstreamreader
- BufferedReader buff = null; //create buffered reader
- URL link = new URL("http://www.gamesig.net:80/maintcheck.php?game=java"); //create new URL object with correct link
- urlConn = link.openConnection(); //open connection
- inStream = new InputStreamReader(urlConn.getInputStream()); //read data
- buff = new BufferedReader(inStream); //read data
- line = buff.readLine(); //get first line
- if (line.equals("0")) {
- array[1] = true; //S4 is online
- }
- line = buff.readLine(); //read next line
- if (line.equals("1")) {
- array[2] = true; //LOCO is online
- }
- } catch (MalformedURLException e) { //incorrect URL format, will never occur as its predefined
- } catch (IOException e1) { //This means, gameSig is offline
- array[0] = false; //GameSig is offline
- return array;
- }
- return array;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment