Here you can find the source of readFile(File in)
public static String readFile(File in)
//package com.java2s; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; public class Main { public static String readFile(File in) { try {/*from ww w . ja va 2 s . c o m*/ return readFile(new FileInputStream(in)); } catch (Exception e) { e.printStackTrace(); return null; } } public static String readFile(InputStream input) { BufferedInputStream reader = null; String rt = null; try { byte[] buffer = new byte[input.available()]; reader = new BufferedInputStream(input); reader.read(buffer); reader.close(); input.close(); rt = new String(buffer); } catch (Exception e) { e.printStackTrace(); return rt; } finally { try { if (input != null) input.close(); if (reader != null) reader.close(); } catch (Exception e) { } } return rt; } }