Class FileSize

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long bytes()
      Gets the number of bytes.
      int compareTo​(FileSize that)  
      boolean equals​(Object o)  
      String formatClosest10()
      Formats this file size in the closest unit of 10^3.
      String formatClosest2()
      Formats this file size in the closest unit of 2^10.
      long GB()
      Gets the number of GB, rounded to the nearest value.
      long GiB()
      Gets the number of GiB, rounded to the nearest value.
      int hashCode()  
      long kB()
      Gets the number of kB, rounded to the nearest value.
      long KiB()
      Gets the number of KiB, rounded to the nearest value.
      long MB()
      Gets the number of MB, rounded to the nearest value.
      long MiB()
      Gets the number of MiB, rounded to the nearest value.
      static FileSize ofBytes​(long bytes)
      Creates a new FileSize object with the given number of bytes.
      static FileSize ofGB​(long GB)
      Creates a new FileSize object with the given number of GB.
      static FileSize ofGiB​(long GiB)
      Creates a new FileSize object with the given number of GiB.
      static FileSize ofKB​(long kB)
      Creates a new FileSize object with the given number of kB.
      static FileSize ofKiB​(long KiB)
      Creates a new FileSize object with the given number of KiB.
      static FileSize ofMB​(long MB)
      Creates a new FileSize object with the given number of MB.
      static FileSize ofMiB​(long MiB)
      Creates a new FileSize object with the given number of MiB.
      static FileSize ofPB​(long PB)
      Creates a new FileSize object with the given number of PB.
      static FileSize ofPiB​(long PiB)
      Creates a new FileSize object with the given number of PiB.
      static FileSize ofTB​(long TB)
      Creates a new FileSize object with the given number of TB.
      static FileSize ofTiB​(long TiB)
      Creates a new FileSize object with the given number of TiB.
      long PB()
      Gets the number of PB, rounded to the nearest value.
      long PiB()
      Gets the number of PiB, rounded to the nearest value.
      long TB()
      Gets the number of TB, rounded to the nearest value.
      long TiB()
      Gets the number of TiB, rounded to the nearest value.
      String toString()  
      static FileSize zero()
      Gets a file size object representing zero bytes.
      static FileSize zeroFileSize()
      Gets a file size object representing zero bytes.
    • Method Detail

      • GB

        public long GB()
        Gets the number of GB, rounded to the nearest value. 1 GB = 1000^3 bytes.
        Returns:
        The number of GB.
      • GiB

        public long GiB()
        Gets the number of GiB, rounded to the nearest value. 1 GiB = 1024^3 bytes.
        Returns:
        The number of GiB.
      • KiB

        public long KiB()
        Gets the number of KiB, rounded to the nearest value. 1 KiB = 1024 bytes.
        Returns:
        The number of KiB.
      • MB

        public long MB()
        Gets the number of MB, rounded to the nearest value. 1 MB = 1000^2 bytes.
        Returns:
        The number of MB.
      • MiB

        public long MiB()
        Gets the number of MiB, rounded to the nearest value. 1 MiB = 1024^2 bytes.
        Returns:
        The number of MiB.
      • PB

        public long PB()
        Gets the number of PB, rounded to the nearest value. 1 PB = 1000^5 bytes.
        Returns:
        The number of PB.
      • PiB

        public long PiB()
        Gets the number of PiB, rounded to the nearest value. 1 TiB = 1024^5 bytes.
        Returns:
        The number of PiB.
      • TB

        public long TB()
        Gets the number of TB, rounded to the nearest value. 1 TB = 1000^4 bytes.
        Returns:
        The number of TB.
      • TiB

        public long TiB()
        Gets the number of TiB, rounded to the nearest value. 1 TiB = 1024^4 bytes.
        Returns:
        The number of TiB.
      • bytes

        public long bytes()
        Gets the number of bytes.
        Returns:
        The number of bytes.
      • formatClosest10

        public String formatClosest10()
        Formats this file size in the closest unit of 10^3. For example, 237kB or 12GB.
        Returns:
        The formatted file size.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • kB

        public long kB()
        Gets the number of kB, rounded to the nearest value. 1 kB = 1000 bytes.
        Returns:
        The number of kB.
      • formatClosest2

        public String formatClosest2()
        Formats this file size in the closest unit of 2^10. For example, 37B, 237KiB or 12GiB.
        Returns:
        The formatted file size.
      • ofBytes

        public static FileSize ofBytes​(long bytes)
        Creates a new FileSize object with the given number of bytes.
        Parameters:
        bytes - The number of bytes.
        Returns:
        The new file size object.
      • ofGB

        public static FileSize ofGB​(long GB)
        Creates a new FileSize object with the given number of GB. 1 GB = 1000^3 bytes.
        Parameters:
        GB - The number of GB.
        Returns:
        The new file size object.
      • ofGiB

        public static FileSize ofGiB​(long GiB)
        Creates a new FileSize object with the given number of GiB. 1 GiB = 1024^3 bytes.
        Parameters:
        GiB - The number of GiB.
        Returns:
        The new file size object.
      • ofKB

        public static FileSize ofKB​(long kB)
        Creates a new FileSize object with the given number of kB. 1 kB = 1000 bytes.
        Parameters:
        kB - The number of kB.
        Returns:
        The new file size object.
      • ofKiB

        public static FileSize ofKiB​(long KiB)
        Creates a new FileSize object with the given number of KiB. 1 KiB = 1024 bytes.
        Parameters:
        KiB - The number of KiB.
        Returns:
        The new file size object.
      • ofMB

        public static FileSize ofMB​(long MB)
        Creates a new FileSize object with the given number of MB. 1 MB = 1000^2 bytes.
        Parameters:
        MB - The number of MB.
        Returns:
        The new file size object.
      • ofMiB

        public static FileSize ofMiB​(long MiB)
        Creates a new FileSize object with the given number of MiB. 1 MiB = 1024^2 bytes.
        Parameters:
        MiB - The number of MiB.
        Returns:
        The new file size object.
      • ofPB

        public static FileSize ofPB​(long PB)
        Creates a new FileSize object with the given number of PB. 1 PB = 1000^5 bytes.
        Parameters:
        PB - The number of PB.
        Returns:
        The new file size object.
      • ofPiB

        public static FileSize ofPiB​(long PiB)
        Creates a new FileSize object with the given number of PiB. 1 PiB = 1024^5 bytes.
        Parameters:
        PiB - The number of PiB.
        Returns:
        The new file size object.
      • ofTB

        public static FileSize ofTB​(long TB)
        Creates a new FileSize object with the given number of TB. 1 TB = 1000^4 bytes.
        Parameters:
        TB - The number of TB.
        Returns:
        The new file size object.
      • ofTiB

        public static FileSize ofTiB​(long TiB)
        Creates a new FileSize object with the given number of TiB. 1 TiB = 1024^4 bytes.
        Parameters:
        TiB - The number of TiB.
        Returns:
        The new file size object.
      • zero

        public static FileSize zero()
        Gets a file size object representing zero bytes.
        Returns:
        The file size object.
      • zeroFileSize

        public static FileSize zeroFileSize()
        Gets a file size object representing zero bytes.
        Returns:
        The file size object.