Class FileSize


  • public final class FileSize
    extends java.lang.Object
    FileSize utility class.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static long GB  
      private static long KB  
      private static Logger LOGGER  
      private static long MB  
      private static long TB  
      private static java.util.regex.Pattern VALUE_PATTERN
      Pattern for string parsing.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private FileSize()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long parse​(java.lang.String string, long defaultValue)
      Converts a string to a number of bytes.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileSize

        private FileSize()
    • Method Detail

      • parse

        public static long parse​(java.lang.String string,
                                 long defaultValue)
        Converts a string to a number of bytes. Strings consist of a floating point value followed by K, M, or G for kilobytes, megabytes, gigabytes, respectively. The abbreviations KB, MB, and GB are also accepted. Matching is case insensitive.
        Parameters:
        string - The string to convert
        defaultValue - The default value if a problem is detected parsing.
        Returns:
        The Bytes value for the string