class Path: Comparable<Path>, Any

Representation of a path.

Fields

Name Description
val fileName: by lazy { _path.fileName.toPath() }
val fileNameWithoutExtension: by lazy { withoutExtension().fileName }
val parent: Path
val extension: String

Constructors

<init>

constructor(uri: String)

Representation of a path.

Parameters

Name Description
uri: String

uniform resource identifier to the file or directory

Methods

exists

fun exists(): Boolean

Returns true, if the file or directory exists.

ReturnValue

Name Description
Boolean

isRegularFile

fun isRegularFile(): Boolean

Returns true, if the path represents a regular file.

ReturnValue

Name Description
Boolean

isDirectory

fun isDirectory(): Boolean

Returns true, if the path represents a directory.

ReturnValue

Name Description
Boolean

walk

fun walk(maxDepth: Int): Sequence<Path>

Returns a sequence of subpaths with maxDepth by walking the file tree.

Parameters

Name Description
maxDepth: Int

maximal depth to be traversed

ReturnValue

Name Description
Sequence<Path>

sequence of Path

resolve

fun resolve(other: Path): Path

Resolves the given path against this path.

Parameters

Name Description
other: Path

the path to resolve against this path

ReturnValue

Name Description
Path

resolved path

withoutExtension

fun withoutExtension(): Path

Returns this path without extension.

ReturnValue

Name Description
Path

path without extension.

relativize

fun relativize(other: Path): Path

Constructs a relative path between this path and the other given path.

Parameters

Name Description
other: Path

other given path

ReturnValue

Name Description
Path

relative path between this path and the other path

updateFileName

fun updateFileName(fileName: String): Path

Returns a path with updated fileName.

Parameters

Name Description
fileName: String

ReturnValue

Name Description
Path

createDirectory

fun createDirectory()

Creates a directory for this path.

ReturnValue

Name Description
Unit

deleteDirectory

fun deleteDirectory()

Deletes the directory of this path.

ReturnValue

Name Description
Unit

deleteDirectoryContents

fun deleteDirectoryContents()

Cleans the content of the directory, but does not delete it.

ReturnValue

Name Description
Unit

isChildOf

infix fun isChildOf(other: Path): Boolean

Returns true if this path is a child of the other path.

Parameters

Name Description
other: Path

ReturnValue

Name Description
Boolean

getParents

fun getParents(baseParent: Path): List<Path>

Returns all parent paths as a list until the baseParent is matched.

Parameters

Name Description
baseParent: Path

limits the list of parents until baseParent is met

ReturnValue

Name Description
List<Path>

list of parent paths of this path

getFileSize

fun getFileSize(): Long

Returns the size of a file or directory.

ReturnValue

Name Description
Long

the length of the file, or recursive size of the directory, provided (in bytes)

getFileSizeToDisplay

fun getFileSizeToDisplay(): String

Returns a human-readable file size like 1MB or 1GB.

ReturnValue

Name Description
String

human-readable size of a file

compareTo

fun compareTo(other: Path): Int

Parameters

Name Description
other: Path

ReturnValue

Name Description
Int

equals

fun equals(other: Any?): Boolean

Parameters

Name Description
other: Any?

ReturnValue

Name Description
Boolean

hashCode

fun hashCode(): Int

ReturnValue

Name Description
Int

toPathN

fun toPathN(): Path

ReturnValue

Name Description
Path

toString

fun toString(): String

ReturnValue

Name Description
String

toFileJ

fun toFileJ(): File

ReturnValue

Name Description
File

toFile

fun toFile(): File

ReturnValue

Name Description
File