Here you can find the source of getFileContents(File file)
Parameter | Description |
---|---|
file | a parameter |
public static String getFileContents(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 w ww .j a va 2 s. c o m * Get contents of a file as string. * * @param file * @return */ public static String getFileContents(File file) { String content = ""; try { Scanner scanner = new Scanner(file); content = scanner.useDelimiter("\\Z").next(); scanner.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } return content; } }