Java InputStream's read(byte[]) method

前端 未结 2 1487
星月不相逢
星月不相逢 2021-01-15 05:33

First some background. Its not needed to answer the actual question, but maybe it\'ll help put things in perspective.

I have written an mp3 library in java (h) which

2条回答
  •  醉梦人生
    2021-01-15 05:58

    And hence my question is: In general, can I not assume that the InputStream's read(byte[]) method will block until the entire number of bytes has been read (or EOF is reached)?

    No. That's why the documentation says "The number of bytes actually read" and "there is an attempt to read at least one byte."

    I need to put the call in a loop and keep reading bytes until the desired number of bytes have been read

    Rather than reinvent the wheel, you can get an already-tested wheel at Jakarta Commons IO.

提交回复
热议问题