void (String info, String filePath, String fileData) { List<String> infoLines = StringUtil.split(info, "\n", false); StringBuilder infoBuilder = new StringBuilder(); for (String line : infoLines) { infoBuilder.append("//INFO: ").append(line); } String correctedFileText = fileData.replaceAll("//\\s?INFO:\\s?.*\n?", "") + infoBuilder.toString(); throw new FileComparisonFailure("Unexpected info", fileData, correctedFileText, new File(filePath).getAbsolutePath()); }