Here you can find the source of readFile(String fileName, String coloredLineIndicator, boolean useSections, boolean isXML)
public static StringBuffer readFile(String fileName, String coloredLineIndicator, boolean useSections, boolean isXML)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStreamReader; public class Main { public static StringBuffer readFile(String fileName) { FileInputStream fis = null; StringBuffer outputBuffer = new StringBuffer(); try {// w w w. j a v a 2 s. c o m fis = new FileInputStream(fileName); InputStreamReader inputStreamReader = new InputStreamReader(fis); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); String bufferString = null; while ((bufferString = bufferedReader.readLine()) != null) { outputBuffer.append(bufferString + '\n'); } fis.close(); } catch (FileNotFoundException fnfex) { return null; } catch (Exception e) { e.printStackTrace(); return null; } return outputBuffer; } public static StringBuffer readFile(String fileName, String coloredLineIndicator, boolean useSections, boolean isXML) { FileInputStream fis = null; StringBuffer outputBuffer = new StringBuffer(); try { fis = new FileInputStream(fileName); InputStreamReader inputStreamReader = new InputStreamReader(fis); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); String bufferString = ""; if (useSections) { bufferString = "<font color=\"red\">" + "****************************** File Header ******************************" + "</font>" + '\n'; outputBuffer.append(bufferString); } while ((bufferString = bufferedReader.readLine()) != null) { if (isXML) { if (bufferString .equals("<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">")) { continue; } } if (bufferString.indexOf(coloredLineIndicator) > 0) { outputBuffer.append("<font color=\"red\">"); outputBuffer.append(bufferString); outputBuffer.append("</font>" + '\n'); } else { outputBuffer.append(bufferString + '\n'); } } if (useSections) { bufferString = "<font color=\"red\">" + "****************************** File Footer ******************************" + "</font>" + '\n'; outputBuffer.append(bufferString); } fis.close(); } catch (FileNotFoundException fnfex) { return null; } catch (Exception e) { e.printStackTrace(); return null; } return outputBuffer; } }