If you do not have access to the Files
class, you can use a native solution.
static String readFile(File file, String charset) throws IOException{ FileInputStream fileInputStream = new FileInputStream(file); byte[] buffer = new byte[fileInputStream.available()]; int length = fileInputStream.read(buffer); fileInputStream.close(); return new String(buffer, 0, length, charset);}