Here you can find the source of readTextFile(File file)
Parameter | Description |
---|---|
file | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static String readTextFile(File file) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { /**/* w w w. jav a 2 s . c om*/ * @param file * @return * @throws IOException */ public static String readTextFile(File file) throws IOException { BufferedReader reader = new BufferedReader(new FileReader(file)); String line; String fileContent = ""; while ((line = reader.readLine()) != null) { fileContent += line.trim(); } reader.close(); return fileContent; } }