private String parseIpFromPing(String ping){
  String ip="";
  if (ping.contains(FROM_PING) || ping.contains(SMALL_FROM_PING)) {
    int index=ping.indexOf(FROM_PING);
    if (index == 0) {
      index=ping.indexOf(SMALL_FROM_PING);
    }
    ip=ping.substring(index + 5);
    if (ip.contains(PARENTHESE_OPEN_PING)) {
      int indexOpen=ip.indexOf(PARENTHESE_OPEN_PING);
      int indexClose=ip.indexOf(PARENTHESE_CLOSE_PING);
      ip=ip.substring(indexOpen + 1,indexClose);
    }
 else {
      ip=ip.substring(0,ip.indexOf("\n"));
      if (ip.contains(":")) {
        index=ip.indexOf(":");
      }
 else {
        index=ip.indexOf(" ");
      }
      ip=ip.substring(0,index);
    }
  }
 else {
    int indexOpen=ping.indexOf(PARENTHESE_OPEN_PING);
    int indexClose=ping.indexOf(PARENTHESE_CLOSE_PING);
    ip=ping.substring(indexOpen + 1,indexClose);
  }
  return ip;
}

private String parseIpFromPing ( String ping ) { String ip = "" ; if ( ping . contains ( FROM_PING ) || ping . contains ( SMALL_FROM_PING ) ) { int index = ping . indexOf ( FROM_PING ) ; if ( index == 0 ) { index = ping . indexOf ( SMALL_FROM_PING ) ; } ip = ping . substring ( index + 5 ) ; if ( ip . contains ( PARENTHESE_OPEN_PING ) ) { int indexOpen = ip . indexOf ( PARENTHESE_OPEN_PING ) ; int indexClose = ip . indexOf ( PARENTHESE_CLOSE_PING ) ; ip = ip . substring ( indexOpen + 1 , indexClose ) ; } else { ip = ip . substring ( 0 , ip . indexOf ( "\n" ) ) ; if ( ip . contains ( ":" ) ) { index = ip . indexOf ( ":" ) ; } else { index = ip . indexOf ( " " ) ; } ip = ip . substring ( 0 , index ) ; } } else { int indexOpen = ping . indexOf ( PARENTHESE_OPEN_PING ) ; int indexClose = ping . indexOf ( PARENTHESE_CLOSE_PING ) ; ip = ping . substring ( indexOpen + 1 , indexClose ) ; } return ip ; }
gets the ip from the string returned by a ping
