Here you can find the source of readFileWithoutLineBreak(String filename, boolean skipEmptyLine)
public static String readFileWithoutLineBreak(String filename, boolean skipEmptyLine) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFileWithoutLineBreak(String filename, boolean skipEmptyLine) throws IOException { StringBuilder sb = new StringBuilder(); BufferedReader br = new BufferedReader(new FileReader(filename)); try {//from ww w. j av a2 s. c om String line; while ((line = br.readLine()) != null) { if (skipEmptyLine && line.trim().length() == 0) { continue; } sb.append(line); } } finally { br.close(); } return sb.toString(); } }