Package kotlin.io
IO API for working with files and streams.
Types
Platform and version requirements: JVM (1.0)
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)
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)
Enum that can be used to specify behaviour of the copyRecursively()
function in exceptional conditions.
Exceptions
Platform and version requirements: JVM (1.0)
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)
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)
A base exception class for file system exceptions.
open class FileSystemException : IOException
Platform and version requirements: JVM (1.0)
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)
Platform and version requirements: JVM (1.0)
Platform and version requirements: JVM (1.0)
Platform and version requirements: JVM (1.0)
Platform and version requirements: JVM (1.0)
Platform and version requirements: JVM (1.0)
Platform and version requirements: JVM (1.0)
Platform and version requirements: JVM (1.0)
Properties
Platform and version requirements: JVM (1.0)
Returns the default buffer size when working with buffered streams.
const val DEFAULT_BUFFER_SIZE: Int
Functions
Platform and version requirements: JVM (1.0)
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)
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)
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)
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
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?)
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)
Creates a new reader for the string.
fun String.reader(): StringReader
Platform and version requirements: JVM (1.0), Native (1.0)
Reads a line of input from the standard input stream.
Platform and version requirements: JVM (1.0)
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