@Test public void givenFileNameWithoutExtension_whenExtractFileNameFromFilePath_thenReturnsTheSameString() { String extractedFileName = extractFileNameFromFilePath(TEST_FILE_NAME_WITH_NO_EXTENSION); assertThat(extractedFileName, is(equalTo(TEST_FILE_NAME_WITH_NO_EXTENSION))); }
public static String extractFileNameFromFilePath(@NonNull String filePath) { checkPreconditionsOnFilePath(filePath); int lastOccurrenceOfFileSeparatorIndex = filePath.lastIndexOf(File.separator); if (lastOccurrenceOfFileSeparatorIndex == -1) return filePath; return filePath.substring(lastOccurrenceOfFileSeparatorIndex + 1); }
FileHelper { public static String extractFileNameFromFilePath(@NonNull String filePath) { checkPreconditionsOnFilePath(filePath); int lastOccurrenceOfFileSeparatorIndex = filePath.lastIndexOf(File.separator); if (lastOccurrenceOfFileSeparatorIndex == -1) return filePath; return filePath.substring(lastOccurrenceOfFileSeparatorIndex + 1); } }
FileHelper { public static String extractFileNameFromFilePath(@NonNull String filePath) { checkPreconditionsOnFilePath(filePath); int lastOccurrenceOfFileSeparatorIndex = filePath.lastIndexOf(File.separator); if (lastOccurrenceOfFileSeparatorIndex == -1) return filePath; return filePath.substring(lastOccurrenceOfFileSeparatorIndex + 1); }  }
FileHelper { public static String extractFileNameFromFilePath(@NonNull String filePath) { checkPreconditionsOnFilePath(filePath); int lastOccurrenceOfFileSeparatorIndex = filePath.lastIndexOf(File.separator); if (lastOccurrenceOfFileSeparatorIndex == -1) return filePath; return filePath.substring(lastOccurrenceOfFileSeparatorIndex + 1); }  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 String extractFileNameFromFilePath(@NonNull String filePath) { checkPreconditionsOnFilePath(filePath); int lastOccurrenceOfFileSeparatorIndex = filePath.lastIndexOf(File.separator); if (lastOccurrenceOfFileSeparatorIndex == -1) return filePath; return filePath.substring(lastOccurrenceOfFileSeparatorIndex + 1); }  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; }