Here you can find the source of readFile(String filePath)
public static String readFile(String filePath) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static String readFile(String filePath) throws IOException { File file = new File(filePath); FileInputStream fin = new FileInputStream(file); ByteArrayOutputStream bs = new ByteArrayOutputStream(); while (true) { int content = fin.read(); if (content == -1) { String content1 = new String(bs.toByteArray(), "UTF-8"); fin.close();//from ww w. ja v a 2s . c o m bs.close(); return content1; } bs.write(content); } } }