main
Alexis Drai 2 years ago
parent 460747e0c2
commit a377c02f1d

@ -0,0 +1,9 @@
/**
* Created to be able to pass ints by refs
*/
public class IntWrapper {
private int value;
public IntWrapper(int value) {this.value = value;}
public int getValue() {return value;}
public void setValue(int value) {this.value = value;}
}

@ -0,0 +1,28 @@
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class WebVerif implements Runnable {
private final String url;
private final IntWrapper status;
public WebVerif(String url, IntWrapper status) {
this.status = status;
this.url = url;
}
@Override
public void run() {
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.connect();
status.setValue(connection.getResponseCode());
} catch (MalformedURLException e) {
status.setValue(HttpURLConnection.HTTP_BAD_REQUEST);
e.printStackTrace();
} catch (IOException ex) {
status.setValue(500);
}
}
}
Loading…
Cancel
Save