zoukankan      html  css  js  c++  java
  • 【FileInputStream类:字节输入流】

    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);
            }
        }
    
    }
    终身学习者
  • 相关阅读:
    2017年暑期实习生招聘(百度)——两道编程题
    携程笔试中的一道编程题
    软工假期预习作业1
    假期作业
    FAFU 1557
    HDU 1028
    POJ 3126
    HDU5108
    POJ 1716
    HDU4790
  • 原文地址:https://www.cnblogs.com/zuixinxian/p/9941131.html
Copyright © 2011-2022 走看看