读取文件内容
package bianchengti; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; /* * 读取文件 */ public class ReadFile { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub InputStream in =new FileInputStream("e:/a.txt"); InputStreamReader isr =new InputStreamReader(in,"GBK"); BufferedReader br =new BufferedReader(isr); StringBuffer sb =new StringBuffer(); String str =null; while((str = br.readLine())!= null) { sb.append(str); } System.out.println("content:"+sb); br.close(); } }
追梦的脚步,永不停息