java 读取文件

来源:互联网 发布:linux fdisk add -t -p 编辑:程序博客网 时间:2024/06/04 17:53
实现从内存中读取文件,在控制台中显示。import java.io.FileInputStream;import java.io.IOException;public class Fileinput {public void f(String address) throws IOException{FileInputStream fin=new FileInputStream(address);byte[] bs=new byte[1024];int count=0;while((count=fin.read(bs))>0){String str=new String(bs,0,count);//反复定义新变量:每一次都 重新定义新变量,接收新读取的数据System.out.println(str);}fin.close();}public static void main(String[] args) throws IOException {Fileinput inFileinput = new Fileinput();inFileinput.f("E://QQPCmgr/Desktop/6.1.txt");}}

原创粉丝点击