Here you can find the source of fileContent(File file, Charset charset)
public static String fileContent(File file, Charset charset)
//package com.java2s; /*//from ww w . j a v a 2 s .co m * SonarQube CSS Plugin * Copyright (C) 2013-2016 Tamas Kende and David RACODON * mailto: kende.tamas@gmail.com and david.racodon@gmail.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import com.google.common.io.Files; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; public class Main { public static String fileContent(File file, Charset charset) { String fileContent; try { fileContent = Files.toString(file, charset); } catch (IOException e) { throw new IllegalStateException("Could not read " + file, e); } return fileContent; } }