W3cubDocs

/Kotlin

Package kotlin.io

IO API for working with files and streams.

Types

Platform and version requirements: JVM (1.0)

FileTreeWalk

This class is intended to implement different file traversal methods. It allows to iterate through all files inside a given directory.

class FileTreeWalk : Sequence<File>
Platform and version requirements: JVM (1.0)

FileWalkDirection

An enumeration to describe possible walk directions. There are two of them: beginning from parents, ending with children, and beginning from children, ending with parents. Both use depth-first search.

enum class FileWalkDirection
Platform and version requirements: JVM (1.0)

OnErrorAction

Enum that can be used to specify behaviour of the copyRecursively() function in exceptional conditions.

enum class OnErrorAction

Exceptions

Platform and version requirements: JVM (1.0)

AccessDeniedException

An exception class which is used when we have not enough access for some operation.

class AccessDeniedException : FileSystemException
Platform and version requirements: JVM (1.0)

FileAlreadyExistsException

An exception class which is used when some file to create or copy to already exists.

class FileAlreadyExistsException : FileSystemException
Platform and version requirements: JVM (1.0)

FileSystemException

A base exception class for file system exceptions.

open class FileSystemException : IOException
Platform and version requirements: JVM (1.0)

NoSuchFileException

An exception class which is used when file to copy does not exist.

class NoSuchFileException : FileSystemException

Extensions for External Classes

Platform and version requirements: JVM (1.0)

java.io.BufferedInputStream

Platform and version requirements: JVM (1.0)

java.io.BufferedReader

Platform and version requirements: JVM (1.0)

java.io.File

Platform and version requirements: JVM (1.0)

java.io.InputStream

Platform and version requirements: JVM (1.0)

java.io.OutputStream

Platform and version requirements: JVM (1.0)

java.io.Reader

Platform and version requirements: JVM (1.0)

java.io.Writer

Platform and version requirements: JVM (1.0)

java.net.URL

Properties

Platform and version requirements: JVM (1.0)

DEFAULT_BUFFER_SIZE

Returns the default buffer size when working with buffered streams.

const val DEFAULT_BUFFER_SIZE: Int

Functions

Platform and version requirements: JVM (1.0)

byteInputStream

Creates a new byte input stream for the string.

fun String.byteInputStream(
    charset: Charset = Charsets.UTF_8
): ByteArrayInputStream
Platform and version requirements: JVM (1.0)

createTempDir

Creates an empty directory in the specified directory, using the given prefix and suffix to generate its name.

fun createTempDir(
    prefix: String = "tmp", 
    suffix: String? = null, 
    directory: File? = null
): File
Platform and version requirements: JVM (1.0)

createTempFile

Creates a new empty file in the specified directory, using the given prefix and suffix to generate its name.

fun createTempFile(
    prefix: String = "tmp", 
    suffix: String? = null, 
    directory: File? = null
): File
Platform and version requirements: JVM (1.0)

inputStream

Creates an input stream for reading data from this byte array.

fun ByteArray.inputStream(): ByteArrayInputStream

Creates an input stream for reading data from the specified portion of this byte array.

fun ByteArray.inputStream(
    offset: Int, 
    length: Int
): ByteArrayInputStream

print

Prints the given message to the standard output stream.

Platform and version requirements: JVM (1.0)
fun print(message: Int)
Platform and version requirements: JVM (1.0)
fun print(message: Long)
Platform and version requirements: JVM (1.0)
fun print(message: Byte)
Platform and version requirements: JVM (1.0)
fun print(message: Short)
Platform and version requirements: JVM (1.0)
fun print(message: Char)
Platform and version requirements: JVM (1.0)
fun print(message: Boolean)
Platform and version requirements: JVM (1.0)
fun print(message: Float)
Platform and version requirements: JVM (1.0)
fun print(message: Double)
Platform and version requirements: JVM (1.0)
fun print(message: CharArray)
Platform and version requirements: Native (1.3)
fun print(message: String)
Platform and version requirements: JVM (1.0), JS (1.1), Native (1.3)
fun print(message: Any?)

println

Prints the given message and the line separator to the standard output stream.

Platform and version requirements: JVM (1.0)
fun println(message: Int)
Platform and version requirements: JVM (1.0)
fun println(message: Long)
Platform and version requirements: JVM (1.0)
fun println(message: Byte)
Platform and version requirements: JVM (1.0)
fun println(message: Short)
Platform and version requirements: JVM (1.0)
fun println(message: Char)
Platform and version requirements: JVM (1.0)
fun println(message: Boolean)
Platform and version requirements: JVM (1.0)
fun println(message: Float)
Platform and version requirements: JVM (1.0)
fun println(message: Double)
Platform and version requirements: JVM (1.0)
fun println(message: CharArray)
Platform and version requirements: Native (1.3)
fun println(message: String)
Platform and version requirements: JVM (1.0), JS (1.1), Native (1.3)
fun println(message: Any?)

Prints the line separator to the standard output stream.

Platform and version requirements: JVM (1.0), JS (1.1), Native (1.3)
fun println()
Platform and version requirements: JVM (1.0)

reader

Creates a new reader for the string.

fun String.reader(): StringReader
Platform and version requirements: JVM (1.0), Native (1.0)

readLine

Reads a line of input from the standard input stream.

fun readLine(): String?
Platform and version requirements: JVM (1.0)

use

Executes the given block function on this resource and then closes it down correctly whether an exception is thrown or not.

fun <T : Closeable?, R> T.use(block: (T) -> R): R

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io/index.html