Here you can find the source of readFile(String directory)
public static String readFile(String directory)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String readFile(String directory) { String path = "", file; String[] S = directory.split("/"); for (int i = 0; i < S.length - 1; i++) path += (S[i] + "/"); file = S[S.length - 1];/*www.ja v a 2 s . com*/ File dir = new File(path); File arq = new File(dir, file); String text = ""; try { FileReader reader = new FileReader(arq); BufferedReader reading = new BufferedReader(reader); String line = ""; while ((line = reading.readLine()) != null) text += line; reader.close(); reading.close(); } catch (IOException e) { e.printStackTrace(); } return text; } }