Class Misc


  • public class Misc
    extends Object
    Miscellaneous conversion functions.
    • Field Detail

      • LINE_SEPARATOR

        public static final String LINE_SEPARATOR
    • Constructor Detail

      • Misc

        public Misc()
    • Method Detail

      • getHostname

        public static String getHostname()
      • toFileSize

        public static long toFileSize​(String value,
                                      long defaultValue)
        Converts the file size to bytes.
        Misc.toFileSize("14GB", 20); // gives out 15032385536
      • toFileSize

        public static String toFileSize​(long value,
                                        boolean format,
                                        boolean floor)
        Converts the input value in bytes to the highest degree of file size, and formats and floors the value, if set to true.
              String mb = Misc.toFileSize(15000000, true); // gives out "14 MB"
              String kb = Misc.toFileSize(150000, false, true); // gives out "146KB"
         
      • getMessageSizeWarnByDefault

        public static long getMessageSizeWarnByDefault()
      • listToString

        public static String listToString​(List<String> list)
        Converts the list to a string. <pre> List<String> list = new ArrayList<>(); list.add("We Are"); list.add(" Frank"); String res = Misc.listToString(list); // res = "We Are Frank" </pre>
      • addItemsToList

        public static void addItemsToList​(Collection<String> collection,
                                          String list,
                                          String collectionDescription,
                                          boolean lowercase)
        Adds items on a string, added by comma separator (ex: "1,2,3"), into a list.
        Parameters:
        collectionDescription - description of the list
      • getFileSystemTotalSpace

        public static String getFileSystemTotalSpace()
      • getFileSystemFreeSpace

        public static String getFileSystemFreeSpace()
      • getAge

        public static String getAge​(long value)
      • getDurationInMs

        public static String getDurationInMs​(long value)
      • parseAge

        public static long parseAge​(String value,
                                    long defaultValue)
      • getBuildOutputDirectory

        public static String getBuildOutputDirectory()
      • getProjectBaseDir

        public static String getProjectBaseDir()
      • addToSortedListUnique

        public static <T> void addToSortedListUnique​(List<T> list,
                                                     T item)
      • addToSortedListNonUnique

        public static <T> void addToSortedListNonUnique​(List<T> list,
                                                        T item)
      • jsonPretty

        public static String jsonPretty​(String json)