Here you can find the source of readFile(File path)
public static String readFile(File path)
//package com.java2s; /************************************************************************************** * Copyright (c) 2013, Universitat Politecnica de Valencia. All rights reserved. * * This program and the accompanying materials are made available under the terms * * of the 3-Clause BSD License which accompanies this distribution, and is available * * at http://www.opensource.org/licenses/BSD-3-Clause. The research leading to these * * results has received funding from the European Community`s Seventh Framework * * Programme (FP7/2007-2013) under the grant agreement FP7-257574 FITTEST. * **************************************************************************************/ import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Main { public static String readFile(File path) { try {//w w w . j a v a 2s. co m return new Scanner(path, "UTF-8").useDelimiter("\\A").next(); } catch (FileNotFoundException ex) { return null; } } }