How do I iterate over all bytes in an inputStream using Groovy, given that it lacks a do-while statement?

后端 未结 3 1364
耶瑟儿~
耶瑟儿~ 2021-01-04 03:17

Given that Groovy does not have a do-while statement, how can I iterate over all bytes in an input stream?

Per a previous version of the Groovy user guide:

3条回答
  •  無奈伤痛
    2021-01-04 04:09

    use this:

    for(;;){ // infinite for
        ...
    
        if( numRead == 0 ){ //condition to break, oppossite to while 
            break
        }
    }
    

提交回复
热议问题