Here you can find the source of readFile(String path)
public static String readFile(String path) throws IOException
//package com.java2s; /**/*from w ww . java 2s . c om*/ * Copyright (C) 2008 Progress Software, Inc. All rights reserved. * http://fusesource.com * * The software in this package is published under the terms of the AGPL license * a copy of which has been included with this distribution in the license.txt file. */ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { public static final int BUFFER_SIZE = 1024; public static String readFile(String path) throws IOException { return readFile(new File(path)); } public static String readFile(File file) throws IOException { StringBuilder sb = new StringBuilder(); BufferedReader reader = new BufferedReader(new FileReader(file)); char[] chars = new char[BUFFER_SIZE]; int length; while ((length = reader.read(chars)) > 0) { sb.append(chars, 0, length); } reader.close(); return sb.toString(); } }