Class TempFileCreator

java.lang.Object
com.google.common.io.TempFileCreator
Direct Known Subclasses:
TempFileCreator.JavaIoCreator, TempFileCreator.JavaNioCreator, TempFileCreator.ThrowingCreator

abstract class TempFileCreator extends Object
Creates temporary files and directories whose permissions are restricted to the current user or, in the case of Android, the current app. If that is not possible (as is the case under the very old Android Ice Cream Sandwich release), then this class throws an exception instead of creating a file or directory that would be more accessible.
  • Field Details

  • Constructor Details

    • TempFileCreator

      private TempFileCreator()
  • Method Details

    • createTempDir

      abstract File createTempDir()
      Throws:
      IllegalStateException - if the directory could not be created (to implement the contract of Files.createTempDir(), such as if the system does not support creating temporary directories securely
    • createTempFile

      abstract File createTempFile(String prefix) throws IOException
      Throws:
      IOException
    • pickSecureCreator

      private static TempFileCreator pickSecureCreator()
    • testMakingUserPermissionsFromScratch

      static void testMakingUserPermissionsFromScratch() throws IOException
      Creates the permissions normally used for Windows filesystems, looking up the user afresh, even if previous calls have initialized the PermissionSupplier fields.

      This lets us test the effects of different values of the user.name system property without needing a separate VM or classloader.

      Throws:
      IOException