Here you can find the source of readFile(String aFile)
Parameter | Description |
---|---|
aFile | aFile |
public static String readFile(String aFile)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; public class Main { /**/* ww w . j ava2 s .c o m*/ * Read a file into a string * * @param aFile aFile * @return file into a string */ public static String readFile(String aFile) { BufferedReader bin = null; StringBuilder sb = new StringBuilder(); try { FileInputStream is = new FileInputStream(aFile); bin = new BufferedReader(new InputStreamReader(is, "UTF-8")); String line = null; while ((line = bin.readLine()) != null) { sb.append(line); sb.append(System.getProperty("line.separator")); } bin.close(); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } return sb.toString(); } }