• java I/O系统总结


    1、 InputStream : 从文件、网络、压缩包等中读取 需要的信息到程序中的变量

        read();     read(byte []b );

        mark(int readlimit);

        reset();  将输入指针返回到当前所做的标记处

        skip(long n);  close();

    子类:  FileInputStream

        FilterInputStream——BufferInputStream,DataInputStream.....(FIleInputStream的子类)

        StringBufferInputStream

    2、 OutputStream :  将内存中的信息 输出到 文件、网络、压缩包中

        write(int n); //指定的字节写入到输出流

        write(byte[] b) ; write(byte[]b,int off,int len);

        flush();  //彻底完成输出,并清空缓冲区

        close();

    3、 File 类

      构造方法:  File(String PathName);  //可以是一个路径,也可以是一个路径+文件 

            File(String fater,String child);

            File(File f,String child);

      成员:    createNewFile();

            .delete(); .getName(); .canRead();canWrtie();exists();length();

           .getAbsolutePath(); isFile(); isDirectory();......

    4、文件输入输出流

    FileInputStream、FileOutputStream 以字节流的形式输入输出

      new FileInputStream(File f);

      new FileInputStream(String name); // 通过给定的文件名创建FileInputStram对象

      read(byte []b) ; 将FIle中的信息读取到 byte数组中

      同样:FIleOutStream();
      write(byte []b); 将信息写入到文件中

      byte[] b = "hello world".getBytes(gbk); //得到
      如果不指定编码格式,得到系统自带的编码格式。可以指定: gbk utf-8 iso-8859-1
      String s_gbk = new String(b, "gbk"); // 与上述过程相反

     FileReader 和 FileWriter (以字符流的形式输出)

       .read(char []c);  .write(String s);  

    5、 带缓存的输入输出流

             

  • 相关阅读:
    面向对象编程
    re模块(正则表达式)
    numpy 模块
    hashlib,logging模块
    模块
    使用Python将Excel中的数据导入到MySQL
    [译]学习IPython进行交互式计算和数据可视化(七)
    [译]学习IPython进行交互式计算和数据可视化(六)
    [译]学习IPython进行交互式计算和数据可视化(五)
    [译]学习IPython进行交互式计算和数据可视化(四)
  • 原文地址:https://www.cnblogs.com/NeilZhang/p/6829717.html
Copyright © 2020-2023  润新知