zoukankan      html  css  js  c++  java
  • 146_IO_原理_分类_标准步骤

    一、概念部分
      流:流动 、流向 从一端移动到另一端 源头与目的地、比如现实生活中的人流、车流。
      程序 与 文件|数组|网络连接|数据库 ,以程序为中心。

    二、io流的分类

      按照流向(以程序为中心)分为:输入流与输出流。

      按照处理数据分为:字节流(可以处理一切)、字符流(只能处理纯文本)

      按照功能分为:节点流(包裹源头、离源头最近)、处理流(提高性能、比如我们用的扩音器)。

    三、字节流和字符流(重点)

      1.字节流

        字节 输入流:InputStream  read(byte[] b) 、read(byte[] b, int off, int len)  +close()          --->FileInputStream

        字节输出流: OutputStream write(byte[] b)  write(byte[] b, int off, int len)  +flush() +close()  --->FileOutputStream

      2.字符流

        字符 输入流:Reader read(char[] cbuf) read(char[] cbuf, int off, int len)  +close()  ---FileReader

        字符输出流:Writer  write(char[] cbuf) write(char[] cbuf, int off, int len) +flush() +close()  --->FileWriter

    四、IO流的操作步骤

      我们以现实生活中的搬家为例(因为程序就是对现实生活中特定事件的模拟)

    现实(搬家) 程序(io流) 总结步骤
    1.关联房子 1.建立与文件联系 1.建立与文件联系
    2.选择搬家公司 2.选择选择对应流(读取|写入) 2.选择流
    3.搬家(卡车大小) 3.操作(数组的大小) 3.操作  数组大小+read 、write
    4.打发搬家公司 4.关闭流 4.释放资源

    如有任何疑问可联系邮箱: 给我发邮件、或直接联系QQ:1584875179 || 点返回首页

  • 相关阅读:
    Python元组、列表、字典
    测试通过Word直接发布博文
    Python环境搭建(windows)
    hdu 4003 Find Metal Mineral 树形DP
    poj 1986 Distance Queries LCA
    poj 1470 Closest Common Ancestors LCA
    poj 1330 Nearest Common Ancestors LCA
    hdu 3046 Pleasant sheep and big big wolf 最小割
    poj 3281 Dining 最大流
    zoj 2760 How Many Shortest Path 最大流
  • 原文地址:https://www.cnblogs.com/aeon/p/10046189.html
Copyright © 2011-2022 走看看