niok-android / ch.tutteli.niok / java.nio.file.Path

Extensions for java.nio.file.Path

absolutePathAsString

val Path.absolutePathAsString: String

Returns Path.toAbsolutePath.Path.toString.

appendBytes

fun Path.appendBytes(array: ByteArray): Unit

Delegates to kotlin.io.appendBytes.

appendText

fun Path.appendText(text: String, charset: Charset = Charsets.UTF_8): Unit

copyRecursively

fun Path.copyRecursively(target: Path, overwrite: Boolean = false, onError: (Path, IOException) -> OnErrorAction = { _, exception -> throw exception }): Boolean

Delegates to kotlin.io.copyRecursively.

copyTo

fun Path.copyTo(outputStream: OutputStream): Long

Delegates to Files.copy with overload for OutputStream.

fun Path.copyTo(target: Path, vararg copyOptions: CopyOption): Path

Delegates to Files.copy.

createDirectories

fun Path.createDirectories(vararg fileAttributes: FileAttribute<*>): Path

Delegates to Files.createDirectories.

createDirectory

fun Path.createDirectory(vararg fileAttributes: FileAttribute<*>): Path

Delegates to Files.createDirectory.

createDirectoryIfNotExists

fun Path.createDirectoryIfNotExists(vararg fileAttributes: FileAttribute<*>): Path

Delegates to createDirectory and swallows a potential java.nio.file.FileAlreadyExistsException.

createFile

fun Path.createFile(vararg fileAttributes: FileAttribute<*>): Path

Delegates to Files.createFile.

createFileIfNotExists

fun Path.createFileIfNotExists(vararg fileAttributes: FileAttribute<*>): Path

Delegates to createFile and swallows a potential java.nio.file.FileAlreadyExistsException.

createLink

fun Path.createLink(link: Path): Path

Creates a new link (directory entry) for this Path. Delegates to Files.createLink.

createSymbolicLink

fun Path.createSymbolicLink(link: Path, vararg fileAttributes: FileAttribute<*>): Path

Creates a symbolic link for this Path. Delegates to Files.createDirectory.

delete

fun Path.delete(): Unit

Delegates to Files.delete.

deleteIfExists

fun Path.deleteIfExists(): Boolean

Delegates to Files.deleteIfExists.

deleteRecursively

fun Path.deleteRecursively(): Boolean

Delegates to kotlin.io.deleteRecursively.

exists

val Path.exists: Boolean

Delegates to Files.exists.

extension

val Path.extension: String

Delegates to kotlin.io.extension.

fileNameAsString

val Path.fileNameAsString: String

Returns Path.getFileName.Path.toString.

fileNameWithoutExtension

val Path.fileNameWithoutExtension: String

Delegates to kotlin.io.nameWithoutExtension.

fileStore

val Path.fileStore: FileStore

Delegates to Files.getFileStore.

followSymbolicLink

fun Path.followSymbolicLink(): Path!

Assumes that this path Path.isSymbolicLink and delegates to Files.readSymbolicLink.

forEachBlock

fun Path.forEachBlock(action: (buffer: ByteArray, bytesRead: Int) -> Unit): Unit
fun Path.forEachBlock(blockSize: Int, action: (buffer: ByteArray, bytesRead: Int) -> Unit): Unit

Delegates to kotlin.io.forEachBlock.

forEachLine

fun Path.forEachLine(charset: Charset = Charsets.UTF_8, action: (line: String) -> Unit): Unit

Delegates to kotlin.io.forEachLine.

getAttribute

fun Path.getAttribute(attribute: String, vararg linkOptions: LinkOption): Any

Delegates to Files.getAttribute.

getFileAttributeView

fun <V : FileAttributeView> Path.getFileAttributeView(vararg linkOptions: LinkOption): V?

Delegates to Files.getFileAttributeView.

invariantSeparatorsPath

val Path.invariantSeparatorsPath: String

Delegates to kotlin.io.invariantSeparatorsPath.

isDirectory

val Path.isDirectory: Boolean

Delegates to Files.isDirectory without LinkOptions.

fun Path.isDirectory(linkOption: LinkOption, vararg furtherLinkOptions: LinkOption): Boolean

Delegates to Files.isDirectory.

isExecutable

val Path.isExecutable: Boolean

Delegates to Files.isExecutable.

isHidden

val Path.isHidden: Boolean

Delegates to Files.isHidden.

isReadable

val Path.isReadable: Boolean

Delegates to Files.isReadable.

isRegularFile

val Path.isRegularFile: Boolean

Delegates to Files.isRegularFile without LinkOptions.

fun Path.isRegularFile(linkOption: LinkOption, vararg furtherLinkOptions: LinkOption): Boolean

Delegates to Files.isRegularFile.

isRooted

val Path.isRooted: Boolean

Delegates to kotlin.io.isRooted.

isSameFile

fun Path.isSameFile(other: Path): Boolean

Delegates to Files.isSameFile.

isSymbolicLink

val Path.isSymbolicLink: Boolean

Delegates to Files.isSymbolicLink.

isWritable

val Path.isWritable: Boolean

Delegates to Files.isWritable.

lastModifiedTime

val Path.lastModifiedTime: FileTime

Delegates to Files.getLastModifiedTime without LinkOptions.

fun Path.lastModifiedTime(linkOption: LinkOption, vararg furtherLinkOptions: LinkOption): FileTime

Delegates to Files.getLastModifiedTime.

move

fun Path.move(target: Path, vararg copyOptions: CopyOption): Path

Delegates to Files.move.

nameWithoutExtension

val Path.nameWithoutExtension: String

Delegates to kotlin.io.nameWithoutExtension.

newBufferedReader

fun Path.newBufferedReader(charset: Charset = Charsets.UTF_8): BufferedReader

Delegates to Files.newBufferedReader.

newBufferedWriter

fun Path.newBufferedWriter(charset: Charset = Charsets.UTF_8, vararg openOptions: OpenOption): BufferedWriter

Delegates to Files.newBufferedWriter.

newByteChannel

fun Path.newByteChannel(vararg openOptions: OpenOption): SeekableByteChannel
fun Path.newByteChannel(openOptions: Set<OpenOption>, vararg fileAttributes: FileAttribute<*>): SeekableByteChannel

Delegates to Files.newByteChannel.

newDirectory

fun Path.newDirectory(dir: String, vararg fileAttributes: FileAttribute<*>): Path

Resolve the given dir and calls createDirectory.

newFile

fun Path.newFile(file: String, vararg fileAttributes: FileAttribute<*>): Path

Resolve the given file and calls createDirectory.

newInputStream

fun Path.newInputStream(vararg openOptions: OpenOption): InputStream

Delegates to Files.newInputStream.

newOutputStream

fun Path.newOutputStream(vararg openOptions: OpenOption): OutputStream

Delegates to Files.newOutputStream.

notExists

val Path.notExists: Boolean

Delegates to Files.notExists without LinkOptions.

fun Path.notExists(linkOption: LinkOption, vararg furtherLinkOptions: LinkOption): Boolean

Delegates to Files.notExists.

owner

val Path.owner: UserPrincipal

Delegates to Files.getLastModifiedTime without LinkOptions.

fun Path.owner(linkOption: LinkOption, vararg furtherLinkOptions: LinkOption): UserPrincipal

Delegates to Files.getLastModifiedTime.

posixFilePersmissions

val Path.posixFilePersmissions: Set<PosixFilePermission>

Delegates to Files.getPosixFilePermissions without LinkOptions.

fun Path.posixFilePersmissions(linkOption: LinkOption, vararg furtherLinkOptions: LinkOption): MutableSet<PosixFilePermission!>!

Delegates to Files.getPosixFilePermissions.

printWriter

fun Path.printWriter(charset: Charset = Charsets.UTF_8): PrintWriter

Delegates to kotlin.io.printWriter.

probeContentType

fun Path.probeContentType(): String

Delegates to Files.probeContentType.

readAllBytes

fun Path.readAllBytes(): ByteArray

Delegates to Files.readAllBytes.

readAllLines

fun Path.readAllLines(charset: Charset = Charsets.UTF_8): List<String>

Delegates to Files.readAllLines.

readAttributes

fun <A : BasicFileAttributes> Path.readAttributes(vararg linkOptions: LinkOption): A
fun Path.readAttributes(attributes: String, vararg linkOptions: LinkOption): Map<String, Any>

Delegates to Files.readAttributes.

reader

fun Path.reader(charset: Charset = Charsets.UTF_8): InputStreamReader

Delegates to kotlin.io.reader.

readSymbolicLink

fun Path.readSymbolicLink(): Path!

Delegates to Files.readSymbolicLink.

readText

fun Path.readText(charset: Charset = Charsets.UTF_8): String

Converts Path.readAllBytes to a string using the given charset.

relativeTo

fun Path.relativeTo(other: Path): Path

Delegates to kotlin.io.relativeToOrNull.

relativeToOrNull

fun Path.relativeToOrNull(other: Path): Path?

Delegates to kotlin.io.relativeToOrNull.

relativeToOrSelf

fun Path.relativeToOrSelf(other: Path): Path

Delegates to kotlin.io.relativeToOrSelf.

resolve

fun Path.resolve(dir: String, first: String, vararg more: String): Path

Converts the given dir, first and more into a Path and Path.resolves it.

setAttribute

fun Path.setAttribute(attribute: String, value: Any, vararg linkOptions: LinkOption): Path!

Delegates to Files.setAttribute.

setLastModifiedTime

fun Path.setLastModifiedTime(fileTime: FileTime): Path!

Delegates to Files.setLastModifiedTime.

setPosixFilePermissions

fun Path.setPosixFilePermissions(perms: Set<PosixFilePermission>): Path!

Delegates to Files.setPosixFilePermissions.

size

val Path.size: Long

Delegates to Files.size.

toRelativeString

fun Path.toRelativeString(base: Path): String

Delegates to kotlin.io.toRelativeString.

useLines

fun <T> Path.useLines(charset: Charset = Charsets.UTF_8, block: (Sequence<String>) -> T): T

Delegates to kotlin.io.useLines.

writeBytes

fun Path.writeBytes(array: ByteArray, vararg openOptions: OpenOption): Path

Delegates to Files.write.

writeLines

fun Path.writeLines(lines: Iterable<CharSequence>, charset: Charset = Charsets.UTF_8, vararg openOptions: OpenOption): Path

Delegates to Files.write.

writer

fun Path.writer(charset: Charset = Charsets.UTF_8): OutputStreamWriter

Delegates to kotlin.io.writer.

writeText

fun Path.writeText(text: String, charset: Charset = Charsets.UTF_8): Unit

Delegates to kotlin.io.writeText.