February 2018
Intermediate to advanced
340 pages
9h 43m
English
The reading from the file is simple because the File type implements both the Reader and Writer interfaces. This way, all functions and approaches applicable to the Reader interface are applicable to the File type. The preceding example shows how to read the file with the use of Scanner and write the content to the bytes buffer (which is more performant than string concatenation). This way, you are able to control the volume of content read from a file.
The second approach with ioutil.ReadFile is simpler but should be used carefully, because it reads the whole file. Keep in mind that the file could be huge and it could threaten the stability of the application.
Read now
Unlock full access