aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2016-03-12 15:36:54 +0100
committerlookshe <github@lookshe.org>2016-03-12 15:36:54 +0100
commitdc26c95b40c3d0f48ed539f91e53c1bff1dceec6 (patch)
treec8cf7dccc382d7492fa54d3fac5be76923555750 /src/main/java/eu/siacs
parent3dc635c6fdeae6024be3510c18821d6f9dc5b550 (diff)
fixed possible NPE
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 ?