Package de.xima.fc.io

Class TempFile

    • Constructor Detail

      • TempFile

        public TempFile​(File file)
        Creates a new temp file. The given file will be deleted when this instance if closed.
        Parameters:
        file - File to wrap.
      • TempFile

        public TempFile​(Path file)
        Creates a new temp file. The given file will be deleted when this instance if closed.
        Parameters:
        file - File to wrap.
    • Method Detail

      • getFile

        public File getFile()
        Returns:
        The wrapped file.
      • getPath

        public Path getPath()
        Returns:
        The wrapped file.
      • create

        public static TempFile create​(Path directory,
                                      String prefix,
                                      String suffix,
                                      FileAttribute<?>... attrs)
                               throws IOException
        Creates a temporary file, wraps it in a TempFile and returns it. This method is a convenience method for wrapping a temporary file created with Files.createTempFile(Path, String, String, FileAttribute[]).
        Parameters:
        directory - the path to directory in which to create the file
        prefix - The prefix string to be used in generating the file's name; may be null.
        suffix - The suffix string to be used in generating the file's name; may be null, in which case ".tmp" is used
        attrs - An optional list of file attributes to set atomically when creating the file
        Returns:
        The newly created temp file.
        Throws:
        IllegalArgumentException - If the prefix or suffix parameters cannot be used to generate a candidate file name.
        UnsupportedOperationException - If the array contains an attribute that cannot be set atomically when creating the directory
        IOException - If an I/O error occurs or dir does not exist.
        SecurityException - In the case of the default provider, and a security manager is installed, the checkWrite method is invoked to check write access to the file.
      • create

        public static TempFile create​(String prefix,
                                      String suffix,
                                      FileAttribute<?>... attrs)
                               throws IOException
        Creates a temporary file, wraps it in a TempFile and returns it. This method is a convenience method for wrapping a temporary file created with Files.createTempFile(String, String, FileAttribute[]).
        Parameters:
        prefix - The prefix string to be used in generating the file's name; may be null.
        suffix - The suffix string to be used in generating the file's name; may be null, in which case ".tmp" is used
        attrs - An optional list of file attributes to set atomically when creating the file
        Returns:
        The newly created temp file.
        Throws:
        IllegalArgumentException - If the prefix or suffix parameters cannot be used to generate a candidate file name.
        UnsupportedOperationException - If the array contains an attribute that cannot be set atomically when creating the directory
        IOException - If an I/O error occurs or dir does not exist.
        SecurityException - In the case of the default provider, and a security manager is installed, the checkWrite method is invoked to check write access to the file.