public static void main(String[] args) throws UnknownHostException {
int timeOut = 3000;
byte[] ip = new byte[]{(byte) 172, (byte) 16, (byte) 39, (byte) 165};
InetAddress address = InetAddress.getByAddress(ip);
IntStream.range(0, 4).forEach(i -> {
try {
if (address.isReachable(timeOut)) {
System.out.println(i + " OK");
} else {
System.out.println(i + "LOSS");
}
} catch (IOException e) {
e.printStackTrace();
}
});
}