Here you can find the source of readFile(String file, Boolean deleteOnExit)
public static String readFile(String file, Boolean deleteOnExit)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.util.function.BiFunction; public class Main { private static BiFunction<String, Boolean, String> fileReader = (file, deleteOnExit) -> { if (file == null) { return null; }/*from ww w . j a v a 2 s. c o m*/ File rerunFile = new File(file); if (deleteOnExit) { rerunFile.deleteOnExit(); } FileReader fileReader = null; BufferedReader bufferedReader = null; try { fileReader = new FileReader(rerunFile); bufferedReader = new BufferedReader(fileReader); StringBuilder fileContents = new StringBuilder(); bufferedReader.lines().forEach(fileContents::append); return fileContents.toString(); } catch (Exception ignored) { return null; } finally { try { if (fileReader != null) fileReader.close(); if (bufferedReader != null) bufferedReader.close(); } catch (Exception ignored) { } } }; public static String readFile(String file, Boolean deleteOnExit) { return fileReader.apply(file, deleteOnExit); } }