Class DiskUtils


  • public class DiskUtils
    extends Object
    This class contains some system utility methods.
    Since:
    3.0
    Author:
    Laurent Jourdren
    • Method Detail

      • du

        public static long du​(Path path)
                       throws IOException
        This method returns the disk usage of a directory or a file.
        Parameters:
        path - the path of the directory or the file
        Returns:
        the disk usage in bytes
        Throws:
        IOException - if an error occurs while getting the disk usage
      • changeDirectoryOwner

        public static void changeDirectoryOwner​(Path directory,
                                                String owner)
                                         throws IOException
        Recursively change the owner of a directory.
        Parameters:
        directory - the directory
        owner - the new owner of the directory
        Throws:
        IOException - if an error occurs while changing the owner of the directory
      • changeDirectoryOwner

        public static void changeDirectoryOwner​(Path directory,
                                                String user,
                                                String group)
                                         throws IOException
        Recursively change the owner of a directory.
        Parameters:
        directory - the directory
        user - the new user of the directory
        group - the new group of the directory
        Throws:
        IOException - if an error occurs while changing the owner of the directory
      • changeDirectoryMode

        public static void changeDirectoryMode​(Path directory,
                                               String mode)
                                        throws IOException
        Recursively change the mode of a directory.
        Parameters:
        directory - the directory
        mode - the new mode of the directory and its files and subdirectories
        Throws:
        IOException - if an error occurs while changing the owner of the directory