Here you can find the source of readFile(String file)
Parameter | Description |
---|---|
file | a parameter |
static String readFile(String file)
//package com.java2s; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Main { /**//w w w .j a v a 2 s .c om * Redid this file to remove sizing requirements and to make it faster * Speeded it up 10 fold. * * @param file */ static String readFile(String file) { try { FileReader reader = new FileReader(file); BufferedReader read = new BufferedReader(reader); StringBuffer b = new StringBuffer(); String s = null; int count = 0; while ((s = read.readLine()) != null) { count++; b.append(s); b.append('\n'); } read.close(); reader.close(); return b.toString(); } catch (IOException e) { return e.getMessage(); } } }