FileInputStream字符流的读操作

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class FileInputStreamTest {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        File fl = new File("D:\\workspace\\FileinputStreamTest\\src\\88.txt");
        FileInputStream fs = null;
        
        try {
            fs = new FileInputStream(fl);
            int c=0;
            
            c = fs.read();
            do{
                System.out.print((char)c);
                c = fs.read();
            }while(c>-1);
            
            
            
            
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally{
            if(fs!=null)
            {
                try {
                    fs.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }

    }

}

 

posted @ 2017-04-19 16:13  与f  阅读(474)  评论(0)    收藏  举报