UrlUtil { protected static String removeExtraDots(String host) { StringBuilder stringBuilder = new StringBuilder(); InputTextReader reader = new InputTextReader(host); while (!reader.eof()) { char curr = reader.read(); stringBuilder.append(curr); if (curr == '.') { char possibleDot = curr; while (possibleDot == '.' && !reader.eof()) { possibleDot = reader.read(); } if (possibleDot != '.') { stringBuilder.append(possibleDot); } } } if (stringBuilder.length() > 0 && stringBuilder.charAt(stringBuilder.length() - 1) == '.') { stringBuilder.deleteCharAt(stringBuilder.length() - 1); } if (stringBuilder.length() > 0 && stringBuilder.charAt(0) == '.') { stringBuilder.deleteCharAt(0); } return stringBuilder.toString(); } private  UrlUtil();   }
@Test(dataProvider = "getExtraDotsStrings") public void testExtraDotsHosts(String input, String expected) { Assert.assertEquals(UrlUtil.removeExtraDots(input), expected); }