aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/eu/olli/cowmoonication/util/Utils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu/olli/cowmoonication/util/Utils.java')
-rw-r--r--src/main/java/eu/olli/cowmoonication/util/Utils.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/eu/olli/cowmoonication/util/Utils.java b/src/main/java/eu/olli/cowmoonication/util/Utils.java
index 8eb08a2..22f32d3 100644
--- a/src/main/java/eu/olli/cowmoonication/util/Utils.java
+++ b/src/main/java/eu/olli/cowmoonication/util/Utils.java
@@ -6,6 +6,9 @@ import org.apache.commons.lang3.text.WordUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DurationFormatUtils;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
@@ -55,6 +58,19 @@ public final class Utils {
}
}
+ public static String toRealPath(Path path) {
+ try {
+ return path.toRealPath().toString();
+ } catch (IOException e) {
+ e.printStackTrace();
+ return "file not found";
+ }
+ }
+
+ public static String toRealPath(File path) {
+ return toRealPath(path.toPath());
+ }
+
/**
* Formats a large number with abbreviations for each factor of a thousand (k, m, ...)
*