private String parseIpFromRoute(String ping) {
            String ip = null;
            try {
                if (ping.contains(Cmd.PING_FROM)) {
                    // Get ip when ttl exceeded
                    int index = ping.indexOf(Cmd.PING_FROM);
                    ip = ping.substring(index + 5);
                    if (ip.contains(Cmd.PING_PAREN_THESE_OPEN)) {
                        int indexOpen = ip.indexOf(Cmd.PING_PAREN_THESE_OPEN);
                        int indexClose = ip.indexOf(Cmd.PING_PAREN_THESE_CLOSE);
                        ip = ip.substring(indexOpen + 1, indexClose);
                    } else {
                        // Get ip when after from
                        ip = ip.substring(0, ip.indexOf("\n"));
                        if (ip.contains(":"))
                            index = ip.indexOf(":");
                        else
                            index = ip.indexOf(" ");
                        ip = ip.substring(0, index);
                    }
                } else if (ping.contains(Cmd.PING)) {
                    int indexOpen = ping.indexOf(Cmd.PING_PAREN_THESE_OPEN);
                    int indexClose = ping.indexOf(Cmd.PING_PAREN_THESE_CLOSE);
                    ip = ping.substring(indexOpen + 1, indexClose);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return ip;
        }
Parsing IP address

@param ping Ping IP and TTL Result
@return IP Address
caprice/kit-cmd/src/main/java/net/qiujuer/genius/kit/cmd/TraceRoute.java