Here you can find the source of readFile(File f)
public static String readFile(File f)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 Carlos Badenes Olmedo. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html//from ww w. j a v a 2s . co m * * Contributor(s): * cbadenes ******************************************************************************/ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFile(File f) { StringBuilder contents = new StringBuilder(); try { BufferedReader input = new BufferedReader(new FileReader(f)); try { String line = null; while ((line = input.readLine()) != null) { contents.append(line); contents.append(System.getProperty("line.separator")); } } finally { input.close(); } } catch (IOException ex) { ex.printStackTrace(); } return contents.toString(); } }