首页 > 其他 > 详细

读取文件内容

时间:2017-09-29 01:32:26      阅读:316      评论:0      收藏:0      [点我收藏+]
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();
    }

}

 

读取文件内容

原文:http://www.cnblogs.com/liuzhenping/p/7609101.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!