Here you can find the source of loadTxtFile(String fileName)
public static String loadTxtFile(String fileName) throws FileNotFoundException, IOException
//package com.java2s; /**/*from w ww. ja va 2 s.c om*/ * Copyright 2010 ZTEsoft Inc. All Rights Reserved. * * This software is the proprietary information of ZTEsoft Inc. * Use is subject to license terms. * * $Tracker List * * $TaskId: $ $Date: 9:24:36 AM (May 9, 2008) $comments: create * $TaskId: $ $Date: 3:56:36 PM (SEP 13, 2010) $comments: upgrade jvm to jvm1.5 * * */ import java.io.*; public class Main { public static String loadTxtFile(String fileName) throws FileNotFoundException, IOException { byte[] bfs = loadFile(fileName); String ret = new String(bfs, "UTF-8"); return ret; } public static byte[] loadFile(String fileName) throws FileNotFoundException, IOException { byte[] retBytes = new byte[0]; File file = new File(fileName); FileInputStream fs = new FileInputStream(fileName); int fileLen = (int) file.length(); retBytes = new byte[fileLen]; fs.read(retBytes); fs.close(); return retBytes; } }