In Java, if you know for certain a file is very small, you can use readBytes() method to read the content in one go instead of read it line by line or using buffer.
readBytes()
Another alternative is to use the nice mapfile builtin:
mapfile < test.file echo "${MAPFILE[@]}"