Class FileUtil.StrictMode

java.lang.Object
com.brightcove.player.util.FileUtil.StrictMode
Enclosing class:
FileUtil

public static class FileUtil.StrictMode extends Object
Provides strict mode equivalents to methods in FileUtil. Strict mode methods will be executed in an io thread, blocking the calling thread until the operation is complete.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    delete(File path)
    Deletes a file or folder, even if the folder is not empty.
    static boolean
    exists(String path)
    Checks if specified path points to a file/directory that exists on the local filesystem.
    static File
    getExternalDirectory(android.content.Context context, String folderType, String name)
    Gets the path to a directory on the primary shared/external storage device where the application can place persistent files it owns.
    static boolean
    Checks if specified path points to a directory that exists on the local filesystem.
    static boolean
    isFile(String path)
    Checks if specified path points to a file that exists on the local filesystem.
    static File
    Checks if the specified path is a directory that can be read from and written into.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StrictMode

      public StrictMode()
  • Method Details

    • makeReadWriteDirectory

      @NonNull public static File makeReadWriteDirectory(@Nullable File path)
      Checks if the specified path is a directory that can be read from and written into. If the directory does not exist, then this method will try to create a readable/writable directory. The operation will be performed on an io thread to adhere to the strict mode policy. The calling thread will be blocked until the operation is complete.
      Parameters:
      path - the path to check/create.
      Returns:
      reference to the validated path.
      Throws:
      IllegalArgumentException - if the download path is invalid or if the download path does not have read or write permissions.
    • getExternalDirectory

      @NonNull public static File getExternalDirectory(@NonNull android.content.Context context, @Nullable String folderType, @Nullable String name)

      Gets the path to a directory on the primary shared/external storage device where the application can place persistent files it owns. These files are internal to the applications, and not typically visible to the user as media.

      Please note that this method will neither check if selected directory exists nor whether it is readable or writable.

      The operation will be performed on an io thread to adhere to the strict mode policy. The calling thread will be blocked until the operation is complete.

      Parameters:
      context - the context
      folderType - the type of files directory to return. May be null for the root of the files directory or one of the following constants for a subdirectory: Environment.DIRECTORY_MUSIC, Environment.DIRECTORY_PODCASTS, Environment.DIRECTORY_RINGTONES, Environment.DIRECTORY_ALARMS, Environment.DIRECTORY_NOTIFICATIONS, Environment.DIRECTORY_PICTURES, or Environment.DIRECTORY_MOVIES.
      name - an optional subfolder name within the selected folder type.
      Returns:
      the path to the selected directory.
      See Also:
    • delete

      public static boolean delete(@NonNull File path)
      Deletes a file or folder, even if the folder is not empty. The operation will be performed on an io thread to adhere to the strict mode policy. The calling thread will be blocked until the operation is complete.
      Parameters:
      path - the path to be deleted.
      Returns:
      false if the file or folder was found, but could not be deleted.
    • isFile

      public static boolean isFile(@Nullable String path)
      Checks if specified path points to a file that exists on the local filesystem. The operation will be performed on an io thread to adhere to the strict mode policy. The calling thread will be blocked until the operation is complete.
      Parameters:
      path - the string path to be checked.
      Returns:
      true is the path points to a local file.
    • isDirectory

      public static boolean isDirectory(@Nullable String path)
      Checks if specified path points to a directory that exists on the local filesystem. The operation will be performed on an io thread to adhere to the strict mode policy. The calling thread will be blocked until the operation is complete.
      Parameters:
      path - the string path to be checked.
      Returns:
      true is the path points to a local directory.
    • exists

      public static boolean exists(@Nullable String path)
      Checks if specified path points to a file/directory that exists on the local filesystem. The operation will be performed on an io thread to adhere to the strict mode policy. The calling thread will be blocked until the operation is complete.
      Parameters:
      path - the string path to be checked.
      Returns:
      true is the path points to a local file or directory.