Class FileUtil


  • public class FileUtil
    extends java.lang.Object
    Utility methods for file manipulation.
    Since:
    6.1.0
    Version:
    $Revision: 24028 $ $Date: 2020-08-13 14:17:03 -0300 (Thu, 13 Aug 2020) $
    • Constructor Detail

      • FileUtil

        public FileUtil()
    • Method Detail

      • getContentType

        @Deprecated
        public static java.lang.String getContentType​(java.io.File file)
                                               throws java.io.IOException
        Deprecated.
        since 8.0.0 replaced by getContentType(IFile).
        Gets content type based on the given file.
        Parameters:
        file - the file.
        Returns:
        content type.
        Throws:
        java.io.IOException - if an IO error occured.
        Since:
        6.1.0
      • getContentType

        public static java.lang.String getContentType​(java.io.InputStream is,
                                                      java.lang.String fileName)
                                               throws java.io.IOException
        Returns the content type based on the given file name and input stream.
        Parameters:
        is - the input stream.
        fileName - the file name.
        Returns:
        the content type based on the given file name and input stream.
        Throws:
        java.io.IOException
        Since:
        8.1.0
      • getContentType

        public static java.lang.String getContentType​(IFile file)
                                               throws java.io.IOException
        Gets content type based on the given file.
        Parameters:
        file - the file.
        Returns:
        the content type based on the given file.
        Throws:
        java.io.IOException
        Since:
        8.0.0
      • calculateWWWFileRelativePath

        public static java.lang.String calculateWWWFileRelativePath​(java.lang.String path)
        Calculates the physical path to the www folder according to a FileConfig path.
        Parameters:
        path - the path stored in the FileConfig.
        Returns:
        adjusted relative path, relative to a web root path.
        Since:
        6.1.0
      • deletePortalFile

        @Deprecated
        public static void deletePortalFile​(PortalFile portalFile)
        Deprecated.
        since 8.0.0 replaced by deletePortalFile(IFile)
        Deletes portal file and all empty ancestor folders.
        Parameters:
        portalFile - the file to be deleted.
        Since:
        6.1.0
      • deletePortalFile

        public static void deletePortalFile​(IFile portalFile)
                                     throws java.io.FileNotFoundException,
                                            FileCouldNotBeDeletedException,
                                            java.io.IOException
        Deletes portal file and all empty ancestor folders.
        Parameters:
        portalFile - the file to be deleted.
        Throws:
        java.io.FileNotFoundException
        FileCouldNotBeDeletedException
        java.io.IOException
        Since:
        8.0.0
      • getWebsiteByFile

        public static IWebsite getWebsiteByFile​(FileConfig fileConfig,
                                                ITransaction transaction)
                                         throws ManagerException,
                                                PortalException
        Returns the website of the given file (the website that contains the file's service instance).
        Parameters:
        fileConfig - the file.
        transaction - the transaction.
        Returns:
        the website of the given file (the website that contains the file's service instance).
        Throws:
        ManagerException
        PortalException
        Since:
        6.2.0
      • getFileResource

        public static IResource getFileResource()
        Returns the file resource.
        Returns:
        the file resource
        Since:
        7.0.0