@NotThreadSafe public class AtomicFileOutputStream extends OutputStream implements ContentHashable
AtomicFileOutputStream
writes to a temporary file and renames on close. This ensures
that writing to the stream is atomic, i.e., all writes become readable only after a close.Constructor and Description |
---|
AtomicFileOutputStream(String path,
AtomicFileOutputStreamCallback ufs,
CreateOptions options)
Constructs a new
AtomicFileOutputStream . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
Optional<String> |
getContentHash() |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
flush
public AtomicFileOutputStream(String path, AtomicFileOutputStreamCallback ufs, CreateOptions options) throws IOException
AtomicFileOutputStream
.path
- path being written toufs
- the calling UnderFileSystem
options
- create options for destination fileIOException
public void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public Optional<String> getContentHash() throws IOException
getContentHash
in interface ContentHashable
IOException
Copyright © 2023. All Rights Reserved.