@Test public void givenAFileNameWithNoExtensionOnTheFile_whenExtractExtensionFromFilePath_thenReturnsAnAbsentOptional() { Optional<String> optionalFileExtension = extractExtensionFromFilePath(TEST_FILE_NAME_WITH_NO_EXTENSION); assertThat(optionalFileExtension, is(equalTo(Optional.<String>absent()))); }
public static Optional<String> extractExtensionFromFilePath(@NonNull String filePath) { checkPreconditionsOnFilePath(filePath); int initialCharacterOfAnExtensionIndex = filePath.lastIndexOf(DOT_SEPARATOR); if (initialCharacterOfAnExtensionIndex == -1) return Optional.absent(); return Optional.of(filePath.substring(initialCharacterOfAnExtensionIndex)); }
FileHelper { public static Optional<String> extractExtensionFromFilePath(@NonNull String filePath) { checkPreconditionsOnFilePath(filePath); int initialCharacterOfAnExtensionIndex = filePath.lastIndexOf(DOT_SEPARATOR); if (initialCharacterOfAnExtensionIndex == -1) return Optional.absent(); return Optional.of(filePath.substring(initialCharacterOfAnExtensionIndex)); } }
FileHelper { public static Optional<String> extractExtensionFromFilePath(@NonNull String filePath) { checkPreconditionsOnFilePath(filePath); int initialCharacterOfAnExtensionIndex = filePath.lastIndexOf(DOT_SEPARATOR); if (initialCharacterOfAnExtensionIndex == -1) return Optional.absent(); return Optional.of(filePath.substring(initialCharacterOfAnExtensionIndex)); }  }
FileHelper { public static Optional<String> extractExtensionFromFilePath(@NonNull String filePath) { checkPreconditionsOnFilePath(filePath); int initialCharacterOfAnExtensionIndex = filePath.lastIndexOf(DOT_SEPARATOR); if (initialCharacterOfAnExtensionIndex == -1) return Optional.absent(); return Optional.of(filePath.substring(initialCharacterOfAnExtensionIndex)); }  static String extractFilePathWithoutExtensionFromFilePath(@NonNull String filePath); static String extractFileNameWithoutExtensionFromFilePath(@NonNull String filePath); static String extractFileNameFromFilePath(@NonNull String filePath); static Optional<String> extractExtensionFromFilePath(@NonNull String filePath); static boolean endsWithJarOrApkExtension(@NonNull String filePath); }
FileHelper { public static Optional<String> extractExtensionFromFilePath(@NonNull String filePath) { checkPreconditionsOnFilePath(filePath); int initialCharacterOfAnExtensionIndex = filePath.lastIndexOf(DOT_SEPARATOR); if (initialCharacterOfAnExtensionIndex == -1) return Optional.absent(); return Optional.of(filePath.substring(initialCharacterOfAnExtensionIndex)); }  static String extractFilePathWithoutExtensionFromFilePath(@NonNull String filePath); static String extractFileNameWithoutExtensionFromFilePath(@NonNull String filePath); static String extractFileNameFromFilePath(@NonNull String filePath); static Optional<String> extractExtensionFromFilePath(@NonNull String filePath); static boolean endsWithJarOrApkExtension(@NonNull String filePath); static final String DOT_SEPARATOR; static final String APK_EXTENSION; static final String JAR_EXTENSION; }