Reads all the bytes from a file. The method ensures that the file is closed when all bytes have been read or an I/O error, or other runtime exception, is thrown.
Note that this method is intended for simple cases where it is convenient to read all bytes into a byte array. It is not intended for reading in large files.
path
| the path to the file |
IOException
| if an I/O error occurs reading from the stream | |
OutOfMemoryError
| if an array of the required size cannot be allocated, for
example the file is larger that 2GB | |
SecurityException
| In the case of the default provider, and a security manager is
installed, the checkRead
method is invoked to check read access to the file. |
Diagram: Files