aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/utils/FileUtils.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/utils/FileUtils.java b/src/main/java/eu/siacs/conversations/utils/FileUtils.java
index 7c2a51c5..967c9b41 100644
--- a/src/main/java/eu/siacs/conversations/utils/FileUtils.java
+++ b/src/main/java/eu/siacs/conversations/utils/FileUtils.java
@@ -153,6 +153,9 @@ public class FileUtils {
* @return last extension or empty string
*/
public static String getLastExtension(final String filename) {
+ if (filename == null || filename.isEmpty()) {
+ return "";
+ }
final int lastDotPosition = filename.lastIndexOf('.');
final String lastPart = lastDotPosition != -1 ?
filename.substring(lastDotPosition + 1) : "";
@@ -164,6 +167,9 @@ public class FileUtils {
* @return second to last extension or empty string
*/
public static String getSecondToLastExtension(final String filename) {
+ if (filename == null || filename.isEmpty()) {
+ return "";
+ }
final int lastDotPosition = filename.lastIndexOf('.');
final int secondToLastDotPosition = filename.lastIndexOf('.', lastDotPosition - 1);
final String secondToLastPart = secondToLastDotPosition != -1 ?