码迷,mamicode.com
首页 > 其他好文 > 详细

读取文件内容

时间:2017-09-29 01:53:40      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:class   col   adl   div   close   fileinput   ack   system   rate   

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();
    }

}

 

读取文件内容

标签:class   col   adl   div   close   fileinput   ack   system   rate   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!