Here you can find the source of readFile(File file, boolean useSystemLineSeparator)
public static String readFile(File file, boolean useSystemLineSeparator)
//package com.java2s; /**/* w w w . j a va 2 s. c o m*/ * Copyright (c) 2007 IBM Corporation 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 * * Contributors: * IBM - Initial API and implementation */ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { public static String readFile(File file, boolean useSystemLineSeparator) { StringBuffer stringBuffer = new StringBuffer(); try { BufferedReader in = new BufferedReader(new FileReader(file)); try { int size = 0; char[] buff = new char[512]; while ((size = in.read(buff)) >= 0) { stringBuffer.append(buff, 0, size); } } finally { in.close(); } } catch (IOException exception) { throw new RuntimeException(exception); } int length = stringBuffer.length(); if (length > 0) { String nl = useSystemLineSeparator ? System.getProperties().getProperty("line.separator") : "\n"; return stringBuffer.toString().replaceAll("\\r\\n", "\n").replaceAll("[\\n|\\r]", nl); } return stringBuffer.toString(); } }