zoukankan      html  css  js  c++  java
  • 字节流,读取 a.txt 文件内容,并打印出来


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

    /**
    字节流,读取 a.txt 文件内容,并打印出来
    */
    public class InputFile {
    public static void main(String[] args) {

    try {
    FileInputStream input = new FileInputStream("a.txt");
    // read() 从此输入流中读取一个数据字节。
    // read(byte[] b) 从此输入流中将最多 b.length 个字节的数据读入一个 byte 数组中。
    byte[] b = new byte[input.available()];
    input.read(b);
    // 打印
    String str=new String(b);
    System.out.println(str);
    input.close();

    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }

    ————————————————
    版权声明:本文为CSDN博主「lyl_」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/li_yuan_long/article/details/79475576

  • 相关阅读:
    Event bubbling
    input/change event practice
    Form event
    Event_Object
    DOM_this keyword
    Random color generator exercise
    DOM_events_addEventListener
    Spring值SpEL
    Spring之使用外部属性文件
    Spring之Bean的作用域
  • 原文地址:https://www.cnblogs.com/muhy/p/11525556.html
Copyright © 2011-2022 走看看