How to write while loop with responseInputStream.read in kotlin android - - while ((i = responseInputStream.read(byteContainer))

Viewed 2104

How to use while loop with responseInputStream.read in kotlin android

my code for while loop in kotlin android

another one

here added responseInputStream read while loop .kt

                val responseInputStream = conn.inputStream
                val responseStringBuffer = StringBuffer()
                val byteContainer = ByteArray(1024)
                var i: Int
                while ((i = responseInputStream.read(byteContainer)) != -1) {
                    responseStringBuffer.append(String(byteContainer, 0, i))
                }
                Log.w("TAG", "res :" + responseStringBuffer.toString())
1 Answers
Related