Here you can find the source of loadTextFile(final String filePath)
public static String loadTextFile(final String filePath) throws IOException
//package com.java2s; /*/* www.ja v a2 s . com*/ * Copyright (c) 2014 Cisco Systems, Inc. and others. 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.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Main { public static String loadTextFile(final String filePath) throws IOException { final FileReader fileReader = new FileReader(filePath); final BufferedReader bufReader = new BufferedReader(fileReader); String line = null; final StringBuilder result = new StringBuilder(); while ((line = bufReader.readLine()) != null) { result.append(line); } bufReader.close(); return result.toString(); } }