Package org.europa.together.utils
Class SocketTimeout
- java.lang.Object
-
- org.europa.together.utils.SocketTimeout
-
public final class SocketTimeout extends Object
Helper Class to iniciate timeouts in connections e.g. Databases, SMTP Servers and so on.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isUrlAvailable(String url)
Check if a URL e.static boolean
timeout(int milliseconds, String uri, int port)
Initiate a timeout after the given time in milliseconds are passed.
-
-
-
Method Detail
-
isUrlAvailable
public static boolean isUrlAvailable(String url)
Check if a URL e. g. www.google.com is available. It is a simple test if a connection to the internet is possible.- Parameters:
url
- as String- Returns:
- true on success
-
timeout
public static boolean timeout(int milliseconds, String uri, int port)
Initiate a timeout after the given time in milliseconds are passed. 1 Second = 1000 Milliseconds. Useful values to interrupt connection are between 3000 and 5000.
The method return a success true when a connection can be established.- Parameters:
milliseconds
- as longuri
- as Stringport
- as int- Returns:
- true on success
-
-