AtomicFileKt

public final class AtomicFileKt


Summary

Public methods

static final @RequiresApi(value = 17) byte[]

Gets the entire content of this file as a byte array.

static final @RequiresApi(value = 17) @NonNull String
AtomicFileKt.readText(AtomicFile receiver, Charset charset)

Gets the entire content of this file as a String using UTF-8 or specified charset.

static final @RequiresApi(value = 17) void
AtomicFileKt.tryWrite(
    AtomicFile receiver,
    Function1<FileOutputStreamUnit> block
)

Perform the write operations inside block on this file.

static final @RequiresApi(value = 17) void
AtomicFileKt.writeBytes(AtomicFile receiver, byte[] array)

Sets the content of this file as an array of bytes.

static final @RequiresApi(value = 17) void
AtomicFileKt.writeText(
    AtomicFile receiver,
    String text,
    Charset charset
)

Sets the content of this file as text encoded using UTF-8 or specified charset.

Public methods

AtomicFileKt.readBytes

@RequiresApi(value = 17)
public static final byte[] AtomicFileKt.readBytes(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.

AtomicFileKt.readText

@RequiresApi(value = 17)
public static final @NonNull String AtomicFileKt.readText(AtomicFile receiver, 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.

AtomicFileKt.tryWrite

@RequiresApi(value = 17)
public static final void AtomicFileKt.tryWrite(
    AtomicFile receiver,
    Function1<FileOutputStreamUnit> 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.

AtomicFileKt.writeBytes

@RequiresApi(value = 17)
public static final void AtomicFileKt.writeBytes(AtomicFile receiver, byte[] array)

Sets the content of this file as an array of bytes.

AtomicFileKt.writeText

@RequiresApi(value = 17)
public static final void AtomicFileKt.writeText(
    AtomicFile receiver,
    String text,
    Charset charset
)

Sets the content of this file as text encoded using UTF-8 or specified charset. If this file exists, it becomes overwritten.