文件读到字符串
//N o w J a v a . c o m 提供 //package com.nowjava; 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 void main(String[] argv) throws Exception { String filePath = "nowjava.com"; System.out.println(file_read(filePath)); } public static String file_read(String filePath) { try { FileInputStream fin = new FileInputStream(new File(filePath)); String ret = convertStreamToString(fin); fin.close(); return ret; } catch (Exception e) {/**from 时代Java**/ return ""; } } public static String convertStreamToString(InputStream is) throws Exception { BufferedReader reader = new BufferedReader( new InputStreamReader(is)); StringBuilder sb =