按文件名读取文件并保存到字符串
/** nowjava.com - 时代Java 提 供 **/ //package com.nowjava; import java.io.*; public class Main { public static String readFile(String filename) { StringBuilder buf = new StringBuilder(); try { BufferedReader input = new BufferedReader(new FileReader( filename)); String line; while ((line = input.readLine()) != null) { buf.append(line); buf.append(System.getProperty("line.separator")); } }