Here you can find the source of readTextFile(File fromFile)
Parameter | Description |
---|---|
fromFile | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static String readTextFile(File fromFile) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { /**/*from ww w .ja va 2 s . c o m*/ * Read the String content from File. * @param fromFile * @return * @throws IOException */ public static String readTextFile(File fromFile) throws IOException { StringBuffer buf = new StringBuffer(); BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fromFile))); String inputLine; while ((inputLine = in.readLine()) != null) { buf.append(inputLine); buf.append('\n'); } in.close(); return buf.toString(); } }