Here you can find the source of readTextFileFully(File file)
public static String readTextFileFully(File file)
//package com.java2s; import java.io.BufferedReader; import java.io.Closeable; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { /**/*from www . j a v a 2s . c om*/ * Will skip lines starting with // */ public static String readTextFileFully(File file) { BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); StringBuilder buffer = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { if (!line.startsWith("//")) { buffer.append(line).append('\n'); } } return buffer.toString(); } catch (IOException e) { throw new RuntimeException(e); } finally { close(reader); } } public static void close(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (Throwable e) { // swallow } } } }