Here you can find the source of readFile(String path)
public static String readFile(String path)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static String readFile(String path) { File myFile = new File(path); FileInputStream fIn;/*from w w w.j a v a2s . co m*/ try { if (!myFile.exists()) { if (myFile.getParentFile() != null) { myFile.getParentFile().mkdirs(); } myFile.createNewFile(); return ""; } fIn = new FileInputStream(myFile); BufferedReader myReader = new BufferedReader(new InputStreamReader(fIn)); String aDataRow = ""; String aBuffer = ""; while ((aDataRow = myReader.readLine()) != null) { aBuffer += aDataRow; } myReader.close(); return aBuffer; } catch (IOException e) { e.printStackTrace(); } return ""; } }