从文件获取字符串
//package com.nowjava; /** n o w j a v a . c o m - 时 代 Java 提供 **/ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String getStringFromFile(String filePath) throws Exception { FileInputStream fin = new FileInputStream(new File(filePath)); /* from N o w J a v a . c o m - 时 代 Java*/ String ret = convertStreamToString(fin); fin.close(); return ret; } public static String convertStreamToString(InputStream is) throws Exception { BufferedReader reader = new BufferedReader( new InputStreamReader(is)); StringBuilder sb = new StringBuilder();