Here you can find the source of readfile(String filename)
static public String readfile(String filename) throws IOException
//package com.java2s; /* Copyright 2012, UCAR/Unidata. See the LICENSE file for more information. *///from w w w .java2 s .c o m import java.io.*; public class Main { static public String readfile(String filename) throws IOException { StringBuilder buf = new StringBuilder(); FileReader file = new FileReader(filename); BufferedReader rdr = new BufferedReader(file); String line; while ((line = rdr.readLine()) != null) { if (line.startsWith("#")) continue; buf.append(line + "\n"); } return buf.toString(); } }