IO编程__字节流__输入

一、代码如下

package www.tainiu.wenjian;

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

public class aa__FileZiJieLiu__V1 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//File f= new File("d:\\Test.txt");
		FileInputStream fis= null;
		try {
		    //fis= new FileInputStream(f);
		    fis= new FileInputStream("d:\\Test.txt");
			byte[] bytes= new byte[1024];
			int n= 0;
			while((n=fis.read(bytes)) != -1) {
				String s= new String(bytes, 0, n);
			    s= new String(bytes, "GBK");
				System.out.println(s);
			}
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {fis.close();} catch (IOException e) {e.printStackTrace();}
		}

	}

}

 

posted @ 2017-10-06 22:21  18513757531  阅读(124)  评论(0编辑  收藏  举报