setOwner

Sets the file owner to the specified value.

@IgnorableReturnValueinline fun Path.setOwner(value: UserPrincipal): Path(source)
import java.nio.file.Paths
import java.nio.file.attribute.UserPrincipal
import kotlin.io.path.setOwner

fun main() {
    val path = Paths.get("/tmp/example.txt")
    val user: UserPrincipal =
        path.fileSystem.userPrincipalLookupService().lookupPrincipalByName("bob")
    path.setOwner(user)   // the returned Path is ignored
}

Source