Here you can find the source of LoadUTF8(InputStream stream)
public static String LoadUTF8(InputStream stream) throws UnsupportedEncodingException, IOException
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; public class Main { public static String LoadUTF8(InputStream stream) throws UnsupportedEncodingException, IOException { BufferedReader in = null; try {/* w w w . ja va 2 s.c o m*/ in = new BufferedReader(new InputStreamReader(stream, "UTF8")); String str; StringBuilder builder = new StringBuilder(); while ((str = in.readLine()) != null) { builder.append(str); builder.append("\n"); } return builder.toString(); } finally { if (in != null) { in.close(); } } } public static String LoadUTF8(String filename) throws UnsupportedEncodingException, IOException { BufferedReader in = null; try { File fileDir = new File(filename); in = new BufferedReader(new InputStreamReader(new FileInputStream(fileDir), "UTF8")); String str; StringBuilder builder = new StringBuilder(); while ((str = in.readLine()) != null) { builder.append(str); builder.append("\n"); } return builder.toString(); } finally { if (in != null) { in.close(); } } } }