Create Core Kotlin IO module

This commit is contained in:
Alexander Molochko
2019-04-16 02:10:13 +03:00
parent 2cc1de2e39
commit c0eb679136
6 changed files with 92 additions and 0 deletions
@@ -1,18 +0,0 @@
package com.baeldung.inputstream
import java.io.InputStream
fun InputStream.readUpToChar(stopChar: Char): String {
val stringBuilder = StringBuilder()
var currentChar = this.read().toChar()
while (currentChar != stopChar) {
stringBuilder.append(currentChar)
currentChar = this.read().toChar()
if (this.available() <= 0) {
stringBuilder.append(currentChar)
break
}
}
return stringBuilder.toString()
}