Here you can find the source of readFile(String filename)
public static String readFile(String filename) throws Exception
//package com.java2s; /******************************************************************************* * Copyright Duke Comprehensive Cancer Center and SemanticBits * /*from ww w .j av a 2 s . c om*/ * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/c3pr/LICENSE.txt for details. ******************************************************************************/ public class Main { public static String readFile(String filename) throws Exception { java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader( Thread.currentThread().getContextClassLoader().getResourceAsStream(filename))); StringBuffer sb = new StringBuffer(); try { String newline = System.getProperty("line.separator"); String tmp = null; while ((tmp = br.readLine()) != null) { sb.append(tmp); sb.append(newline); } } finally { if (br != null) br.close(); return (sb.toString()); } } }