I don't know the solution to the reported problem but your method readFileAsString() looks to be flawed. It assumes that a single byte can be cast to a char which in general is not true. Converting bytes to characters requires the use of a character coder/decoder.
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.