Here you can find the source of fileToString(File file)
Parameter | Description |
---|---|
file | The text file to read. |
public static String fileToString(File file)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Main { /**//from ww w . j a v a2 s . c om * Reads a complete text file. * * @param file The text file to read. * @return the file content. */ public static String fileToString(File file) { try { return new Scanner(file).useDelimiter("\\Z").next(); } catch (FileNotFoundException e) { throw new RuntimeException("Failed to read file: " + file, e); } } }