首页 > 其他 > 详细

【FileInputStream类:字节输入流】

时间:2018-11-11 00:31:28      阅读:167      评论:0      收藏:0      [点我收藏+]
package test;

import java.io.FileInputStream;
import java.io.IOException;

/**
 * @author shusheng
 * @description
 * @Email shusheng@yiji.com
 * @date 2018/11/9 16:16
 */
public class FileInputStreamDemo1 {
    /*
     *字节输入流操作步骤:
     *A:创建字节输入流对象
     *B:调用read()方法读取数据,并把数据显示在控制台
     *C:释放资源
     *
     *读取数据的方式:
     *A:int read():一次只能读一个字节
     *B: int read(byte[] b):一次读取一个字节数组
     */
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("fos.txt");
        int by = 0;
        while((by=fis.read())!=-1){
            /**不能识别汉字*/
            System.out.println((char)by);
        }
    }

}

 

【FileInputStream类:字节输入流】

原文:https://www.cnblogs.com/zuixinxian/p/9941131.html

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