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

.net - Bulk insert via Dapper is slower than inserting rows one-by-one -

shared memory - gstreamer shmsrc and shmsink with h264 data -

java - is not an enclosing class / new Intent Cannot Resolve Constructor -