Here you can find the source of readFile(File file)
public static String readFile(File file) throws IOException
//package com.java2s; /***//www . j ava2 s .c o m * Copyright (C) 2010 Johan Henriksson * This code is under the Endrov / BSD license. See www.endrov.net * for the full text and how to cite. */ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { /** * Read file into string */ public static String readFile(File file) throws IOException { StringBuffer bf = new StringBuffer(); BufferedReader br = new BufferedReader(new FileReader(file)); String line; while ((line = br.readLine()) != null) { bf.append(line); bf.append("\n"); } //TODO: should read file exactly as is. do not use readline! br.close(); return bf.toString(); } }