Here you can find the source of readFile(String fullPath)
public static String readFile(String fullPath) throws Exception
//package com.java2s; /*//from w ww . ja va 2s. c o m * FileUtil.java * Copyright (C) 2007-3-19 <JustinLei@gmail.com> * * 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. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ import java.io.BufferedReader; import java.io.FileReader; public class Main { public static String readFile(String fullPath) throws Exception { BufferedReader reader = new BufferedReader(new FileReader(fullPath)); if (reader == null) return null; StringBuilder builder = new StringBuilder(""); String line = null; while ((line = reader.readLine()) != null) { builder.append(line + "/n"); } return builder.toString(); } }