AtomicFileKt
public final class AtomicFileKt
Summary
Public methods |
|
|---|---|
static final @NonNull byte[] |
readBytes(@NonNull AtomicFile receiver)Gets the entire content of this file as a byte array. |
static final @NonNull String |
readText(@NonNull AtomicFile receiver, @NonNull Charset charset)Gets the entire content of this file as a String using UTF-8 or specified |
static final void |
tryWrite(Perform the write operations inside |
static final void |
writeBytes(@NonNull AtomicFile receiver, @NonNull byte[] array)Sets the content of this file as an |
static final void |
Sets the content of this file as |
Public methods
readBytes
public static final @NonNull byte[] readBytes(@NonNull AtomicFile receiver)
Gets the entire content of this file as a byte array.
This method is not recommended on huge files. It has an internal limitation of 2 GB file size.
readText
public static final @NonNull String readText(@NonNull AtomicFile receiver, @NonNull Charset charset)
Gets the entire content of this file as a String using UTF-8 or specified charset.
This method is not recommended on huge files. It has an internal limitation of 2 GB file size.
tryWrite
public static final void tryWrite(
@NonNull AtomicFile receiver,
@NonNull Function1<@NonNull FileOutputStream, Unit> block
)
Perform the write operations inside block on this file. If block throws an exception the write will be failed. Otherwise the write will be applied atomically to the file.
writeBytes
public static final void writeBytes(@NonNull AtomicFile receiver, @NonNull byte[] array)
Sets the content of this file as an array of bytes.