Package org.kohsuke.stapler.framework.io
Class AtomicFileWriter
- java.lang.Object
-
- java.io.Writer
-
- org.kohsuke.stapler.framework.io.AtomicFileWriter
-
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
public class AtomicFileWriter extends Writer
BufferedFileWriter
that uses UTF-8.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 Summary
Constructors Constructor Description AtomicFileWriter(File f)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
commit()
void
flush()
File
getTemporaryFile()
Until the data is committed, this file captures the written content.void
write(char[] cbuf, int off, int len)
void
write(int c)
void
write(String str, int off, int len)
-
-
-
Constructor Detail
-
AtomicFileWriter
public AtomicFileWriter(File f) throws IOException
- Throws:
IOException
-
-
Method Detail
-
write
public void write(int c) throws IOException
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
public void write(String str, int off, int len) throws IOException
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
public void write(char[] cbuf, int off, int len) throws IOException
- Specified by:
write
in classWriter
- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
commit
public void commit() throws IOException
- Throws:
IOException
-
getTemporaryFile
public File getTemporaryFile()
Until the data is committed, this file captures the written content.
-
-