Code cleanup and formatting. Migrated to java 1.8.
[svjatoslav_commons.git] / src / main / java / eu / svjatoslav / commons / file / FilePathParser.java
index 3fa1894..905ea22 100755 (executable)
@@ -1,10 +1,10 @@
 /*
  * Svjatoslav Commons - shared library of common functionality.
- * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ * Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
  * 
  * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
+ * modify it under the terms of version 3 of the GNU Lesser General Public License
+ * or later as published by the Free Software Foundation.
  */
 
 package eu.svjatoslav.commons.file;
@@ -13,54 +13,52 @@ import java.io.File;
 
 public class FilePathParser {
 
-       public static String getFileExtension(final File file) {
-               final String fullFileName = file.getName();
+    public static String getFileExtension(final File file) {
+        final String fullFileName = file.getName();
 
-               return getFileExtension(fullFileName);
-       }
+        return getFileExtension(fullFileName);
+    }
 
-       public static String getFileExtension(final String fullFileName) {
-               final int dot = fullFileName.lastIndexOf('.');
-               String fileExtension;
-               if (dot == -1)
-                       fileExtension = "";
-               else {
-                       fileExtension = fullFileName.substring(dot + 1);
-                       fileExtension = fileExtension.toLowerCase();
-               }
+    public static String getFileExtension(final String fullFileName) {
+        final int dot = fullFileName.lastIndexOf('.');
+        String fileExtension;
+        if (dot == -1)
+            fileExtension = "";
+        else {
+            fileExtension = fullFileName.substring(dot + 1);
+            fileExtension = fileExtension.toLowerCase();
+        }
 
-               return fileExtension;
-       }
+        return fileExtension;
+    }
 
-       public static String getFileNameWithoutExtension(final File file) {
-               final String fullFileName = file.getName();
-               return getFileNameWithoutExtension(fullFileName);
-       }
+    public static String getFileNameWithoutExtension(final File file) {
+        final String fullFileName = file.getName();
+        return getFileNameWithoutExtension(fullFileName);
+    }
 
-       public static String getFileNameWithoutExtension(final String fullFileName) {
-               final int dot = fullFileName.lastIndexOf('.');
-               String fileName;
-               if (dot == -1)
-                       fileName = fullFileName;
-               else
-                       fileName = fullFileName.substring(0, dot);
+    public static String getFileNameWithoutExtension(final String fullFileName) {
+        final int dot = fullFileName.lastIndexOf('.');
+        String fileName;
+        if (dot == -1)
+            fileName = fullFileName;
+        else
+            fileName = fullFileName.substring(0, dot);
 
-               return fileName;
-       }
+        return fileName;
+    }
 
-       public static String getFileSizeDescription(long fileSize) {
-               String suffix = "b";
+    public static String getFileSizeDescription(long fileSize) {
+        String suffix = "b";
 
-               if (fileSize > (1024 * 1024 * 10)) {
-                       fileSize = fileSize / (1024 * 1024);
-                       suffix = "Mb";
-               } else if (fileSize > (1024 * 10)) {
-                       fileSize = fileSize / 1024;
-                       suffix = "Kb";
-               }
+        if (fileSize > (1024 * 1024 * 10)) {
+            fileSize = fileSize / (1024 * 1024);
+            suffix = "MiB";
+        } else if (fileSize > (1024 * 10)) {
+            fileSize = fileSize / 1024;
+            suffix = "KiB";
+        }
 
-               final String fileSizeString = String.valueOf(fileSize) + " " + suffix;
-
-               return fileSizeString;
-       }
+        return String.valueOf(fileSize) + " " + suffix;
+    }
 }