Module org.elasticsearch.security
Class SecurityFiles
java.lang.Object
org.elasticsearch.xpack.security.support.SecurityFiles
-
Method Summary
-
Method Details
-
writeFileAtomically
public static <K,V> void writeFileAtomically(Path path, Map<K, V> map, Function<Map.Entry<K, V>, String> transform) Atomically writes to the specified file a line per entry in the specified map using the specified transform to convert each entry to a line. The writing is done atomically in the following sense: first the lines are written to a temporary file and if the writing succeeds then the temporary file is moved to the specified path, replacing the file if it exists. If a failure occurs, any existing file is preserved, and the temporary file is cleaned up.- Type Parameters:
K- the key type of the map entriesV- the value type of the map entries- Parameters:
path- the pathmap- the map whose entries to transform into linestransform- the transform to convert each map entry to a line
-