From e72f4091975838edf4ec6edf8b98c8214241a069 Mon Sep 17 00:00:00 2001 From: lookshe Date: Sat, 12 Mar 2016 14:15:39 +0100 Subject: removed duplicated source --- .../eu/siacs/conversations/utils/FileUtils.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/main/java/eu/siacs/conversations/utils/FileUtils.java') diff --git a/src/main/java/eu/siacs/conversations/utils/FileUtils.java b/src/main/java/eu/siacs/conversations/utils/FileUtils.java index c5d0c3b0..727891ae 100644 --- a/src/main/java/eu/siacs/conversations/utils/FileUtils.java +++ b/src/main/java/eu/siacs/conversations/utils/FileUtils.java @@ -147,4 +147,27 @@ public class FileUtils { public static boolean isMediaDocument(Uri uri) { return "com.android.providers.media.documents".equals(uri.getAuthority()); } + + /** + * @param filename The filename to extract extension from + * @return last extension or empty string + */ + public static String getLastExtension(final String filename) { + final int lastDotPosition = filename.lastIndexOf('.'); + final String lastPart = lastDotPosition != -1 ? + filename.substring(lastDotPosition + 1) : ""; + return lastPart; + } + + /** + * @param filename The filename to extract extension from + * @return second to last extension or empty string + */ + public static String getSecondToLastExtension(final String filename) { + final int lastDotPosition = filename.lastIndexOf('.'); + final int secondToLastDotPosition = filename.lastIndexOf('.', lastDotPosition - 1); + final String secondToLastPart = secondToLastDotPosition != -1 ? + filename.substring(secondToLastDotPosition + 1, lastDotPosition - 1) : ""; + return secondToLastPart; + } } -- cgit v1.2.3