Here you can find the source of readTextFile(File file)
public static String readTextFile(File file) throws IOException
//package com.java2s; /*/*from www . ja v a2 s . com*/ * This file is part of the Jose Project * see http://jose-chess.sourceforge.net/ * (c) 2002-2006 Peter Sch?fer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * */ import java.io.*; public class Main { /** * read a text file */ public static String readTextFile(File file) throws IOException { FileReader in = new FileReader(file); StringWriter out = new StringWriter(); copyReader(in, out); in.close(); out.close(); return out.toString(); } /** * copies the contens of a stream */ public static void copyReader(Reader in, Writer out) throws IOException { char[] buffer = new char[4096]; for (;;) { int count = in.read(buffer, 0, 4096); if (count < 0) break; out.write(buffer, 0, count); } } }