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

后端 未结 3 1354
耶瑟儿~
耶瑟儿~ 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 03:57

    The groovy (version 1.8+) way would be like this:

    inputStream.eachByte(BUFFER_SIZE) { buffer, numRead ->
        ...
    }
    

提交回复
热议问题