I'm using a basic check that checks if certain text is on a website, and if the text is not present it exits the program
if (!getURL("http://ift.tt/2zm5cZt").contains("auth:true")) {
System.exit(0);
}
so if auth:true isn't present, it closes the program.
The method for I'm using for the above getURL is this
public String getURL(String link) {
try {
URL url = new URL(link);
HttpURLConnection huc3 = ( HttpURLConnection ) url.openConnection ();
huc3.setRequestMethod ("HEAD");
huc3.connect () ;
int code3 = huc3.getResponseCode();
if(code3 != HttpURLConnection.HTTP_OK) {
System.exit(0);
}
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
StringBuilder str = new StringBuilder();
String inputLine;
while ((inputLine = reader.readLine()) != null) {
str.append(inputLine);
}
reader.close();
return str.toString();
} catch (Exception e) {
shutdown();
System.exit(0);
throw new RuntimeException("Couldn't properly connect to internet.");
}
}
This should read the webpage and check if the webpage contains the text used in the first if statement which is "auth:true". There is also a check to see if the URL is malformed or not that will also exit the program, this is the same for checking if the user has internet connection.
Now the problem is, that for some users of my program it seems that this check is completely ignored, allowing them to run the program even if the webpage does not contain the auth:true string. This is happening to 2 of my users, the operating systems they are using is linux and windows 10. But for some reason the rest of my users the check works, even though they are on similar operating systems (windows 10).
I don't know what could be causing this so any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire