Here you can find the source of getFileContent(File file)
String
Parameter | Description |
---|---|
file | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static String getFileContent(File file) throws IOException
//package com.java2s; /**/* w w w .j a v a 2 s .com*/ * This file is part of LogiSima (http://www.logisima.com). * * maven-testrunner-plugin is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * maven-testrunner-plugin is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with maven-testrunner-plugin. If not, see <http://www.gnu.org/licenses/>. * * @author Beno?t Simard * @See https://github.com/sim51/maven-testrunner-plugin */ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { /** * Method to retrive the content of a file in a <code>String</code> * * @param file * @return * @throws IOException */ public static String getFileContent(File file) throws IOException { BufferedReader br = new BufferedReader(new FileReader(file)); String content = ""; String strLine; while ((strLine = br.readLine()) != null) { content += strLine + "\n"; } return content; } }