StringBuffer sBuffer = new StringBuffer("5646467894649746456"); for (int i = 0; i < sBuffer.length(); i++) { if (i%3==1){ sBuffer.insert((i+1),"/"); } } System.out.println(sBuffer);