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


this question has answer here:

how use while loop responseinputstream.read in kotlin android

my code 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()) 

kotlin don't java, can't composing multi-expression in single line. should break one-line expressions multi-lines, example:

while(true){   val i= responseinputstream.read(bytecontainer);    if(i==-1) break;    responsestringbuffer.append(string(bytecontainer, 0, i)) } 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -