Vedi questa recente discussione in cui ne abbiamo parlato.

P.S. ip.substring(0,ip.length()-3)+String.valueOf(i); non è granché.