Here you can find the source of getFileContents(String filePath)
public static String getFileContents(String filePath)
//package com.java2s; // License as published by the Free Software Foundation; either import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Scanner; public class Main { public static String getFileContents(String filePath) { try (InputStream stream = new FileInputStream(filePath)) { return getTextStreamContents(stream); } catch (final IOException ex) { throw new IllegalArgumentException(ex); }// w w w . ja va 2 s. c o m } public static String getTextStreamContents(InputStream input) { final Scanner scanner = new Scanner(input); scanner.useDelimiter("\\Z"); return scanner.next(); } }