Here you can find the source of readFile(File from)
public static StringBuffer readFile(File from) throws IOException
//package com.java2s; /**/*from www . j a v a 2 s .co m*/ * Util.java * @author John Green * 27-Oct-2002 * www.joanju.com * * Copyright (c) 2002 Joanju Limited. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * */ import java.io.*; public class Main { /** Read the contents of a file into a StringBuffer */ public static StringBuffer readFile(File from) throws IOException { BufferedReader in = new BufferedReader(new FileReader(from)); StringWriter sWriter = new StringWriter(); BufferedWriter out = new BufferedWriter(sWriter); int c; while ((c = in.read()) != -1) out.write(c); in.close(); out.close(); return sWriter.getBuffer(); } }