Here you can find the source of readFile(String file)
public static String readFile(String file) throws IOException, FileNotFoundException
//package com.java2s; //License from project: Apache License import java.io.FileNotFoundException; import java.io.IOException; import java.io.File; import java.io.BufferedReader; import java.io.FileReader; public class Main { public static String readFile(String file) throws IOException, FileNotFoundException { if (!(new File(file).exists())) { throw new FileNotFoundException("Could not find " + file); }//www .j av a2s . c o m BufferedReader reader = new BufferedReader(new FileReader(file)); String content = ""; String line = ""; while ((line = reader.readLine()) != null) { content += line + "\r\n"; } reader.close(); int c = content.lastIndexOf("\r\n"); if (c > 0) { content = content.substring(0, c); } return content; } }