Here you can find the source of fileToString(String filename)
Parameter | Description |
---|---|
filename | The file to turn into a string |
public static String fileToString(String filename) throws FileNotFoundException, IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { /**/*from www. j av a2 s. c o m*/ * Returns the string representation of a given file. * @param filename The file to turn into a string */ public static String fileToString(String filename) throws FileNotFoundException, IOException { StringBuffer sb = new StringBuffer(); BufferedReader in = new BufferedReader(new FileReader(filename)); String str; while ((str = in.readLine()) != null) sb.append(str); in.close(); return sb.toString(); } }