Class FileUtil


  • public class FileUtil
    extends 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

        public static String getContentType​(InputStream is,
                                            String fileName)
                                     throws 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:
        IOException
        Since:
        8.1.0
      • getContentType

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

        public static String calculateWWWFileRelativePath​(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
      • 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