Interface FileAccessService

  • All Known Implementing Classes:
    FileAccessServiceImpl

    public interface FileAccessService
    A service used to provide the basic functionality required to access the underlying file system. Note: Never store unencrypted sensitive information, such as passwords, personal data, credit card numbers, etc..
    Author:
    Alexander Pelov
    • Method Detail

      • getTemporaryFile

        File getTemporaryFile()
                       throws IOException
        This method returns a created temporary file. After you close this file it is not guaranteed that you will be able to open it again nor that it will contain any information. Note: DO NOT store unencrypted sensitive information in this file
        Returns:
        The created temporary file
        Throws:
        IOException - If the file cannot be created
      • getTemporaryDirectory

        File getTemporaryDirectory()
                            throws IOException
        This method returns a created temporary directory. Any file you create in it will be a temporary file. Note: If there is no opened file in this directory it may be deleted at any time. Note: DO NOT store unencrypted sensitive information in this directory
        Returns:
        The created directory
        Throws:
        IOException - If the directory cannot be created
      • getPrivatePersistentFile

        File getPrivatePersistentFile​(String fileName,
                                      FileCategory category)
                               throws Exception
        This method returns a file specific to the current user. It may not exist, but it is guaranteed that you will have the sufficient rights to create it. This file should not be considered secure because the implementor may return a file accessible to everyone. Generally it will reside in current user's homedir, but it may as well reside in a shared directory. Note: DO NOT store unencrypted sensitive information in this file
        Parameters:
        fileName - The name of the private file you wish to access
        category - The classification of the file.
        Returns:
        The file
        Throws:
        Exception - Thrown if there is no suitable location for the persistent file
      • getPrivatePersistentDirectory

        File getPrivatePersistentDirectory​(String dirName,
                                           FileCategory category)
                                    throws Exception
        This method creates a directory specific to the current user. This directory should not be considered secure because the implementor may return a directory accessible to everyone. Generally, it will reside in current user's homedir, but it may as well reside in a shared directory. It is guaranteed that you will be able to create files in it. Note: DO NOT store unencrypted sensitive information in this file
        Parameters:
        dirName - The name of the private directory you wish to access.
        category - The classification of the directory.
        Returns:
        The created directory.
        Throws:
        Exception - Thrown if there is no suitable location for the persistent directory.
      • getDefaultDownloadDirectory

        File getDefaultDownloadDirectory()
                                  throws IOException
        Returns the default download directory depending on the operating system.
        Returns:
        the default download directory depending on the operating system
        Throws:
        IOException - if it I/O error occurred
      • createFailSafeTransaction

        FailSafeTransaction createFailSafeTransaction​(File file)
        Creates a failsafe transaction which can be used to safely store informations into a file.
        Parameters:
        file - The file concerned by the transaction, null if file is null.
        Returns:
        A new failsafe transaction related to the given file.