import java.io.BufferedReader;import java.io.File;import java.io.FileReader;import java.io.IOException;public class FileReaderUtil { /** * 读文件到String * @param fileName * @return * @throws Exception */ public static String readFile(String fileName) throws Exception { File myFile=new File(fileName); String fileContent = ""; if(!myFile.exists()) { System.err.println("Can't Find " + fileName); } try { BufferedReader in = new BufferedReader(new FileReader(myFile)); String str ; while ((str = in.readLine()) != null) { fileContent = fileContent + str ; } in.close(); } catch (IOException e) { e.getStackTrace(); } return fileContent; } }