Ultra Geile Studenten Benutzer Oberfläche (UGSBO)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
940 B

  1. package com.ugsbo.FirewallOfDeath;
  2. import java.io.IOException;
  3. import java.net.HttpURLConnection;
  4. import java.net.URL;
  5. import java.net.UnknownHostException;
  6. class NetzFunktion {
  7. /***
  8. * sendet einen Ping an google
  9. * @return boolean können wir google erreichen oder nicht?
  10. * @throws IOException
  11. * @throws UnknownHostException
  12. */
  13. public static boolean pingTogoogle() throws IOException,UnknownHostException {
  14. //Googel IP adresse
  15. try {
  16. URL url = new URL("http://www.google.com");
  17. //open a connection to that source
  18. HttpURLConnection urlConnect = (HttpURLConnection)url.openConnection();
  19. //Gibt es keine Verbindung schlägt diese Zeile fehl.
  20. @SuppressWarnings("unused")
  21. Object objData = urlConnect.getContent();
  22. }catch (Exception e) {
  23. e.printStackTrace();
  24. return false;
  25. }
  26. return true;
  27. }
  28. }