类 ApplicationTemp
- 从以下版本开始:
- 4.0 2022/2/20 23:28
- 作者:
- Phillip Webb, Harry Yang
-
字段概要
字段修饰符和类型字段说明static final ApplicationTempprivate Pathprivate final Class<?>private static final String -
构造器概要
构造器构造器说明Create a newApplicationTempinstance.ApplicationTemp(Class<?> sourceClass) Create a newApplicationTempinstance for the specified source class. -
方法概要
修饰符和类型方法说明static PathcreateDirectory(String subDir) Using default instance to create temp directoryprivate PathcreateDirectory(Path path) static PathcreateFile(String prefix) Using default instance to create temp filecreateFile(String subDir, String prefix) Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name.createFile(String subDir, String prefix, String suffix) Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name.getDir()Return the directory to be used for application specific temp files.Return a sub-directory of the application temp.private FileAttribute<?>[]getFileAttributes(FileSystem fileSystem) private PathgetPath()private Pathprivate static StringgetTempSubDir(Class<?> sourceClass) toString()
-
字段详细资料
-
TEMP_SUB_DIR
-
instance
-
sourceClass
-
path
-
-
构造器详细资料
-
ApplicationTemp
public ApplicationTemp()Create a newApplicationTempinstance. -
ApplicationTemp
Create a newApplicationTempinstance for the specified source class.- 参数:
sourceClass- the source class ornull
-
-
方法详细资料
-
toString
-
getDir
Return the directory to be used for application specific temp files.- 返回:
- the application temp directory
- 抛出:
UncheckedIOException- failed to create base temp dir
-
getDir
Return a sub-directory of the application temp.- 参数:
subDir- the sub-directory name- 返回:
- a sub-directory
- 抛出:
UncheckedIOException- failed to create subdir
-
createFile
Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name. The resultingPathis associated with the sameFileSystemas the given directory.The details as to how the name of the file is constructed is implementation dependent and therefore not specified. Where possible the
prefixandsuffixare used to construct candidate names in the same manner as theFile.createTempFile(String, String, File)method.As with the
File.createTempFilemethods, this method is only part of a temporary-file facility. Where used as a work files, the resulting file may be opened using theDELETE_ON_CLOSEoption so that the file is deleted when the appropriateclosemethod is invoked. Alternatively, ashutdown-hook, or theFile.deleteOnExit()mechanism may be used to delete the file automatically.The
attrsparameter is optionalfile-attributesto set atomically when creating the file. Each attribute is identified by itsname. If more than one attribute of the same name is included in the array then all but the last occurrence is ignored. When no file attributes are specified, then the resulting file may have more restrictive access permissions to files created by theFile.createTempFile(String, String, File)method.- 参数:
subDir- the path to directory in which to create the fileprefix- the prefix string to be used in generating the file's name; may benull- 返回:
- the path to the newly created file that did not exist before this method was invoked
- 抛出:
IllegalArgumentException- if the prefix or suffix parameters cannot be used to generate a candidate file nameUncheckedIOException- if an I/O error occurs ordirdoes not exist
-
createFile
Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name. The resultingPathis associated with the sameFileSystemas the given directory.The details as to how the name of the file is constructed is implementation dependent and therefore not specified. Where possible the
prefixandsuffixare used to construct candidate names in the same manner as theFile.createTempFile(String, String, File)method.As with the
File.createTempFilemethods, this method is only part of a temporary-file facility. Where used as a work files, the resulting file may be opened using theDELETE_ON_CLOSEoption so that the file is deleted when the appropriateclosemethod is invoked. Alternatively, ashutdown-hook, or theFile.deleteOnExit()mechanism may be used to delete the file automatically.The
attrsparameter is optionalfile-attributesto set atomically when creating the file. Each attribute is identified by itsname. If more than one attribute of the same name is included in the array then all but the last occurrence is ignored. When no file attributes are specified, then the resulting file may have more restrictive access permissions to files created by theFile.createTempFile(String, String, File)method.- 参数:
subDir- the path to directory in which to create the fileprefix- the prefix string to be used in generating the file's name; may benullsuffix- the suffix string to be used in generating the file's name; may benull, in which case ".tmp" is used- 返回:
- the path to the newly created file that did not exist before this method was invoked
- 抛出:
IllegalArgumentException- if the prefix or suffix parameters cannot be used to generate a candidate file nameUncheckedIOException- if an I/O error occurs ordirdoes not exist
-
getPath
-
getTempSubDir
-
createDirectory
- 抛出:
UncheckedIOException- failed to create temp dir
-
getFileAttributes
-
getTempDirectory
-
createDirectory
Using default instance to create temp directory -
createFile
Using default instance to create temp file
-