Here you can find the source of fileContentsToString(File errFile)
Parameter | Description |
---|---|
errFile | File to be read |
Parameter | Description |
---|---|
IOException | an exception |
public static String fileContentsToString(File errFile) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { /**//from w w w . j a v a2s.co m * Utility method to read in contents of file and concatenate into String * @param errFile File to be read * @return String containing contents of file * @throws IOException */ public static String fileContentsToString(File errFile) throws IOException { String errFileString = null; BufferedReader br = null; StringBuffer sb = new StringBuffer(); br = new BufferedReader(new FileReader(errFile)); String errLine = br.readLine(); while (errLine != null) { sb.append(errLine); errLine = br.readLine(); } errFileString = sb.toString(); return errFileString; } }