- Регистрация
- 1 Мар 2015
- Сообщения
- 6,839
- Баллы
- 155
fun invertBinaryFile(inputFilePath: String, outputFilePath: String) {
val inputFile = File(inputFilePath)
val outputFile = File(outputFilePath)
inputFile.inputStream().use { inputStream ->
outputFile.outputStream().use { outputStream ->
val buffer = ByteArray(1024)
var bytesRead: Int
while (inputStream.read(buffer).also { bytesRead = it } != -1) {
val invertedBuffer = buffer.map { it.inv() }.toByteArray() // Bitwise NOT
outputStream.write(invertedBuffer, 0, bytesRead)
}
}
}
}
val inputFile = File(inputFilePath)
val outputFile = File(outputFilePath)
inputFile.inputStream().use { inputStream ->
outputFile.outputStream().use { outputStream ->
val buffer = ByteArray(1024)
var bytesRead: Int
while (inputStream.read(buffer).also { bytesRead = it } != -1) {
val invertedBuffer = buffer.map { it.inv() }.toByteArray() // Bitwise NOT
outputStream.write(invertedBuffer, 0, bytesRead)
}
}
}
}