Here you can find the source of readTextFile(String fileName)
public static String readTextFile(String fileName) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static String readTextFile(String fileName) throws IOException { // return new String(Files.readAllBytes(Paths.get(fileName)), StandardCharsets.UTF_8); /* Java 7 approach, which doesn't seem to work in Android 4.1 */ File file = new File(fileName); FileInputStream fis = new FileInputStream(file); byte[] data = new byte[(int) file.length()]; fis.read(data);// w ww . ja v a 2 s . c o m fis.close(); return new String(data, "UTF-8"); } }