java小工具(二)读取文本文件的内容到string
//读取文本文件的内容到string
public static String TXT2String(String txt_file) throws IOException{
StringBuilder builder = new StringBuilder();
BufferedReader reader = new BufferedReader(new FileReader(txt_file));
String s = null;
while ((s=reader.readLine())!=null) {
builder.append(System.lineSeparator()+s);
}
reader.close();
return builder.toString();
}