Package org.eclipse.aether.util
Class FileUtils
java.lang.Object
org.eclipse.aether.util.FileUtils
A utility class to write files.
- Since:
- 1.9.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA collocated temporary file, that resides next to a "target" file, and is removed when closed.static interfaceA file writer, that accepts aPathto write some content to.static interfaceA temporary file, that is removed when closed. -
Method Summary
Modifier and TypeMethodDescriptionstatic FileUtils.TempFileCreates aFileUtils.TempFile.static FileUtils.CollocatedTempFilenewTempFile(Path file) Creates aFileUtils.TempFilefor given file.static voidwriteFile(Path target, FileUtils.FileWriter writer) Writes file without backup.static voidwriteFileWithBackup(Path target, FileUtils.FileWriter writer) Writes file with backup copy (appends ".bak" extension).
-
Method Details
-
newTempFile
Creates aFileUtils.TempFile. It will be in the default temporary-file directory. Returned instance should be handled in try-with-resource construct and created temp file is removed on close, if exists.- Throws:
IOException
-
newTempFile
Creates aFileUtils.TempFilefor given file. It will be in same directory where given file is, and will reuse its name for generated name. Returned instance should be handled in try-with-resource construct and created temp file once ready can be moved to passed infileparameter place.The
filenor it's parent directories have to exist. The parent directories are created if needed.- Throws:
IOException
-
writeFile
Writes file without backup.- Parameters:
target- that is the target file (must be file, the path must have parent).writer- the writer that will accept aPathto write content to.- Throws:
IOException- if at any step IO problem occurs.
-
writeFileWithBackup
Writes file with backup copy (appends ".bak" extension).- Parameters:
target- that is the target file (must be file, the path must have parent).writer- the writer that will accept aPathto write content to.- Throws:
IOException- if at any step IO problem occurs.
-