Class AtomicFiles
- java.lang.Object
-
- org.spongepowered.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.
- Since:
- 4.0.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BufferedWriter
atomicBufferedWriter(Path path, Charset charset)
Creates and returns an "atomic" writer for the given path.static Callable<BufferedWriter>
atomicWriterFactory(Path path, Charset charset)
Creates and returns an "atomic" writer factory for the given path.
-
-
-
Method Detail
-
atomicWriterFactory
public static Callable<BufferedWriter> atomicWriterFactory(Path path, Charset charset)
Creates and returns an "atomic" writer factory for the given path.- Parameters:
path
- path the complete file should be written tocharset
- the charset to be used by the writer- Returns:
- a new writer factory
- Since:
- 4.0.0
-
atomicBufferedWriter
public static BufferedWriter atomicBufferedWriter(Path path, Charset charset) throws IOException
Creates and returns an "atomic" writer for the given path.- Parameters:
path
- the pathcharset
- the charset to be used by the writer- Returns:
- a new writer factory
- Throws:
IOException
- for any underlying filesystem errors- Since:
- 4.0.0
-
-