Here you can find the source of readFiles(String[] files, String encoding)
public static String readFiles(String[] files, String encoding)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String readFiles(File[] files, String encoding) { StringBuffer buffer = new StringBuffer(); for (File file : files) { buffer.append(readFile(file, encoding)); }//from w w w . ja v a 2s . c om return buffer.toString(); } public static String readFiles(String[] files, String encoding) { StringBuffer buffer = new StringBuffer(); for (String pathname : files) { File file = new File(pathname); buffer.append(readFile(file, encoding)); } return buffer.toString(); } public static void readFile(InputStream inputStream) throws IOException { InputStreamReader in = new InputStreamReader(inputStream); BufferedReader reader = new BufferedReader(in); String line; while ((line = reader.readLine()) != null) { System.out.println(line); } reader.close(); } public static String readFile(File file, String encoding) { StringBuffer buffer = new StringBuffer(); try { FileInputStream inputStream = new FileInputStream(file); InputStreamReader inputStreamReader = new InputStreamReader(inputStream, encoding); BufferedReader reader = new BufferedReader(inputStreamReader); String tempString = null; while ((tempString = reader.readLine()) != null) { buffer.append(tempString + "\n"); } reader.close(); } catch (Exception e) { } return buffer.toString(); } public static String readFile(String filename, String encoding) { return readFile(new File(filename), encoding); } public static String readFile(File file) { StringBuffer buffer = new StringBuffer(); try { FileInputStream inputStream = new FileInputStream(file); InputStreamReader inputStreamReader = new InputStreamReader(inputStream); BufferedReader reader = new BufferedReader(inputStreamReader); String tempString = null; while ((tempString = reader.readLine()) != null) { buffer.append(tempString + "\n"); } reader.close(); } catch (Exception e) { } return buffer.toString(); } public static String readFile(String filename) { return readFile(new File(filename)); } }