Package ninja.leaping.configurate.loader
Class AtomicFiles
java.lang.Object
ninja.leaping.configurate.loader.AtomicFiles
public final class AtomicFiles extends Object
A utility for creating "atomic" file writers.
An atomic writer copies any existing file at the given path to a temporary location, then writes to the same temporary location, before moving the file back to the desired output path once the write is fully complete.
-
Method Summary
Modifier and Type Method Description static @NonNull BufferedWriter
createAtomicBufferedWriter(@NonNull Path path, @NonNull Charset charset)
Creates and returns an "atomic" writer for the given path.static @NonNull Callable<BufferedWriter>
createAtomicWriterFactory(@NonNull Path path, @NonNull Charset charset)
Creates and returns an "atomic" writer factory for the given path.
-
Method Details
-
createAtomicWriterFactory
public static @NonNull Callable<BufferedWriter> createAtomicWriterFactory(@NonNull Path path, @NonNull Charset charset)Creates and returns an "atomic" writer factory for the given path.- Parameters:
path
- The pathcharset
- The charset to be used by the writer- Returns:
- The writer factory
-
createAtomicBufferedWriter
public static @NonNull BufferedWriter createAtomicBufferedWriter(@NonNull Path path, @NonNull Charset charset) throws IOExceptionCreates and returns an "atomic" writer for the given path.- Parameters:
path
- The pathcharset
- The charset to be used by the writer- Returns:
- The writer factory
- Throws:
IOException
- For any underlying filesystem errors
-