Package hudson.util

Class AtomicFileWriter

java.lang.Object
java.io.Writer
hudson.util.AtomicFileWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable

public class AtomicFileWriter extends Writer
Buffered FileWriter that supports atomic operations.

The write operation is atomic when used for overwriting; it either leaves the original file intact, or it completely rewrites it with new contents.

Author:
Kohsuke Kawaguchi
  • Constructor Details

    • AtomicFileWriter

      public AtomicFileWriter(File f) throws IOException
      Writes with UTF-8 encoding.
      Throws:
      IOException
    • AtomicFileWriter

      @Deprecated public AtomicFileWriter(@NonNull File f, @Nullable String encoding) throws IOException
      Parameters:
      encoding - File encoding to write. If null, platform default encoding is chosen.
      Throws:
      IOException
    • AtomicFileWriter

      public AtomicFileWriter(@NonNull Path destinationPath, @NonNull Charset charset) throws IOException
      Parameters:
      destinationPath - the destination path where to write the content when committed.
      charset - File charset to write.
      Throws:
      IOException
    • AtomicFileWriter

      @Deprecated public AtomicFileWriter(@NonNull Path destinationPath, @NonNull Charset charset, boolean integrityOnFlush, boolean integrityOnClose) throws IOException
      DO NOT USE THIS METHOD, OR YOU WILL LOSE DATA INTEGRITY.
      Parameters:
      destinationPath - the destination path where to write the content when committed.
      charset - File charset to write.
      integrityOnFlush - do not force writing to disk when flushing
      integrityOnClose - do not force writing to disk when closing
      Throws:
      IOException
  • Method Details