Using JDK 8 or above:
no external libraries used
You can create a new String object from the file content (Using classes from java.nio.file
package):
public String readStringFromFile(String filePath) throws IOException { String fileContent = new String(Files.readAllBytes(Paths.get(filePath))); return fileContent;}