Here you can find the source of readTextFile(final String fileNamePath, final String charsetName)
public static String readTextFile(final String fileNamePath, final String charsetName) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.FileInputStream; import java.io.IOException; import java.nio.charset.Charset; public class Main { /**/*from w ww.jav a2 s.c om*/ * Liest Text Datei */ public static String readTextFile(final String fileNamePath) throws IOException { return readTextFile(fileNamePath, Charset.defaultCharset().name()); } /** * Liest Text Datei */ public static String readTextFile(final String fileNamePath, final String charsetName) throws IOException { byte[] text = readFile(fileNamePath); return new String(text, charsetName); } public static byte[] readFile(final String fileNamePath) throws IOException { FileInputStream input = null; byte[] daten = null; try { input = new FileInputStream(fileNamePath); daten = new byte[input.available()]; input.read(daten); } finally { if (input != null) { input.close(); } } return daten; } }