kotlin.io.java.io.File.forEachBlock

forEachBlock

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

Platform and version requirements: JVM

Reads file by byte blocks and calls action for each block read. Block has default size which is implementation-dependent. This functions passes the byte array and amount of bytes in the array to the action function.

You can use this function for huge files.

Parameters

action - function to process file blocks.

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

Platform and version requirements: JVM

Reads file by byte blocks and calls action for each block read. This functions passes the byte array and amount of bytes in the array to the action function.

You can use this function for huge files.

Parameters

action - function to process file blocks.

blockSize - size of a block, replaced by 512 if it's less, 4096 by default.

© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io/java.io.-file/for-each-block.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部