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 . j av a2 s.c o m import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { static public String readfile(String filename) throws IOException { StringBuilder buf = new StringBuilder(); File xx = new File(filename); if (!xx.canRead()) { int x = 0; } 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(); } }