Exceptions priority in InputStream.read(byte[], int, int)

Raffaello Giulietti raffaello.giulietti at gmail.com
Tue Jun 23 14:34:05 UTC 2020


Hi,

the InputStream.read(byte[], int, int) method [1] can throw
* IOException
* NullPointerException
* IndexOutOfBoundsException

Is there a recommended priority for the conditions associated to the 
exceptions to be checked? For example, if the arguments are invalid and 
the stream is already closed, which exception shall be thrown?


Greetings
Raffaello

----

[1] 
https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/io/InputStream.html#read(byte%5B%5D,int,int)


More information about the core-libs-dev mailing list