I need to switch to another if on current connection, connection refused, or if current IP do not exist. Here is a part of code:
String [] server= {"10.201.30.200", "10.66.20.70",}; // Servers array
public void Telnet(String[] server) {
try {
out2 = new PrintStream(new FileOutputStream("output.txt"));
String [] hrnc = {"HRNC01_", "HRNC02_", "HRNC03_","NRNC01_", "NRNC02_"};
for (int i = 0; i < server.length; i++) {
// Connect to the specified server
if (server[i].equals("10.201.30.200")) {
// Commands via telnet
} else if (server[i].equals("10.66.20.70")) {
// Commands
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
For example if first IP don't exist i need to connect to the next server.