• 十、输入/输出


      流:一组有序的数据序列。

    1、输入流

      所有输入流都是抽象类InputStream或抽象类Reader的子类。

      方法:read()、mark()、reset()、skip()、markSupport()、close()

    2、输出流

      所有输出流都是抽象类OuputStream或抽象类Writer的子类

      方法:write()、flush()、close()

    3、File类

      io包中唯一代表磁盘文件本身的对象。

    (1)文件的创建与删除

      1)File file = new File("d:/1.txt");

      2)new File(String parent,String child)

      3)new File(File f,String child)

      createNewFile()、delete()

    (2)获取文件信息

      方法:getName()、canRead()、canWrite()、exits()、length()、getAbsolutePath()、getParent()、isFile()、isDirectory()、isHidden()、lastModified()

    4、文件输入/输出流

      对应字节或字节数组

    (1)FileInputStream与FIleOutputStream类

      FileInputStream构造方法:

      1)FileInputStream(String name)

      2)FileOutputStream(File file)

    (2)FIleReader类和FileWriter类

      对应字符

      read()、write()

    5、带缓存的输入/输入流

    (1)BufferedInputStream类与BufferedOutputStream类

      BufferedInputStream构造方法:

        1)BufferedInputStream(InputStream in)  //默认32个字节

        2)BufferedInputStream(InputStream in,int size)

    (2)BufferedReader类与BufferedWriter类

      方法:read()、readLine()、write()、flush()、nextLine()

    6、数据输入/输出流

      DataInputStream类与DataOutputStream类

      方法:writreBytes(String s)、writeChar(String s)、writeUTF(String s)

         readUTF()

    7、ZIP压缩输入/输出流

    (1)压缩文件  ZipOutputStream

      方法:putNextEntry(ZipEntry e)、write(byte[] b,int off,int len)、finish()、

    setComment(String comment)

    (2)解压缩  ZipInputStream

      方法:read()、available()、closeEntry()、skip()、getNextEntry()、createZipEntry()

      

  • 相关阅读:
    Linux filesystem
    centos 下 gradle 编译打包 apk
    python SSL 错误
    nginx 缓存配置
    nginx 反向代理配置
    redhat 网卡绑定
    磁盘阵列
    Centos 安装Django2.1
    python pyquery 基本用法
    python 爬虫之-- 正则表达式
  • 原文地址:https://www.cnblogs.com/yl-saber/p/6003159.html
Copyright © 2020-2023  润新知