@Test public void testAddNumberToFileNameWithoutPoint() { String fileName = "abcfile"; String newFileName = StringHelper.addNumberToFileName(fileName, 2); assertThat(newFileName).isEqualTo(StringHelper.UNKNOWN_DATATYPE); }
public static String addNumberToFileName(String fileName, int number) { if (fileName.contains(".")) { String newFileName = fileName; String fileType = getDataTypeFromFileName(fileName); newFileName = fileName.substring(0, fileName.lastIndexOf(".")); return newFileName + number + "." + fileType; } else { return UNKNOWN_DATATYPE; } }
StringHelper { public static String addNumberToFileName(String fileName, int number) { if (fileName.contains(".")) { String newFileName = fileName; String fileType = getDataTypeFromFileName(fileName); newFileName = fileName.substring(0, fileName.lastIndexOf(".")); return newFileName + number + "." + fileType; } else { return UNKNOWN_DATATYPE; } } }
StringHelper { public static String addNumberToFileName(String fileName, int number) { if (fileName.contains(".")) { String newFileName = fileName; String fileType = getDataTypeFromFileName(fileName); newFileName = fileName.substring(0, fileName.lastIndexOf(".")); return newFileName + number + "." + fileType; } else { return UNKNOWN_DATATYPE; } }  }
StringHelper { public static String addNumberToFileName(String fileName, int number) { if (fileName.contains(".")) { String newFileName = fileName; String fileType = getDataTypeFromFileName(fileName); newFileName = fileName.substring(0, fileName.lastIndexOf(".")); return newFileName + number + "." + fileType; } else { return UNKNOWN_DATATYPE; } }  static boolean isValidEmail(final String email); static String getDataTypeFromFileName(String fileName); static String addNumberToFileName(String fileName, int number); static boolean isEmpty(final String queryString); static String getTextForLanguage(String text, String lang); }
StringHelper { public static String addNumberToFileName(String fileName, int number) { if (fileName.contains(".")) { String newFileName = fileName; String fileType = getDataTypeFromFileName(fileName); newFileName = fileName.substring(0, fileName.lastIndexOf(".")); return newFileName + number + "." + fileType; } else { return UNKNOWN_DATATYPE; } }  static boolean isValidEmail(final String email); static String getDataTypeFromFileName(String fileName); static String addNumberToFileName(String fileName, int number); static boolean isEmpty(final String queryString); static String getTextForLanguage(String text, String lang); static final String UNKNOWN_DATATYPE; static final Pattern EMAIL_PATTERN; }