zoukankan      html  css  js  c++  java
  • apache commons-io相关介绍-IOUtils类

    IOUtils类

    IOUtils类普通的IO流(InputStream, OutputStream)/读写器(Reader、Writer)操作函数,该类提供下列静态函数用于输入输出操作。

    • closeQuietly these methods close a stream ignoring nulls and exceptions
    • toXxx/read these methods read data from a stream
    • write these methods write data to a stream
    • copy these methods copy all the data from one stream to another
    • contentEquals these methods compare the content of two streams

    关闭流

    close(URLConnection)
    closeQuietly(Closeable)
    closeQuietly(InputStream)
    closeQuietly(OutputStream)
    closeQuietly(Reader)
    closeQuietly(Writer)
    closeQuietly(ServerSocket)
    closeQuietly(Socket)
    closeQuietly(Selector)
    

    比较流或者阅读器的内容

    contentEquals(InputStream, InputStream)
    contentEquals(Reader, Reader)
    contentEqualsIgnoreEOL(Reader, Reader)
    

    复制操作

    copy(InputStream, OutputStream)
    copy(InputStream, Writer)
    copy(InputStream, Writer, String)
    copy(InputStream, Writer, Charset)
    copy(Reader, OutputStream)
    copy(Reader, OutputStream, String)
    copy(Reader, OutputStream, Charset)
    copy(Reader, Writer)
    copyLarge(InputStream, OutputStream)
    copyLarge(InputStream, OutputStream, byte[])
    copyLarge(InputStream, OutputStream, long, long)
    copyLarge(InputStream, OutputStream, long, long, byte[])
    copyLarge(Reader, Writer)
    copyLarge(Reader, Writer, char[])
    copyLarge(Reader, Writer, long, long)
    copyLarge(Reader, Writer, long, long, char[])
    

    行迭代器

    lineIterator(InputStream, String)
    lineIterator(InputStream, Charset)
    lineIterator(Reader)
    

    读取内容

    read(InputStream, byte[])
    read(InputStream, byte[], int, int)
    read(Reader, char[])
    read(Reader, char[], int, int)
    readFully(InputStream, byte[])
    readFully(InputStream, byte[], int, int)
    readFully(Reader, char[])
    readFully(Reader, char[], int, int)
    readLines(InputStream)
    readLines(InputStream, String)
    readLines(InputStream, Charset)
    readLines(Reader)
    

    定位读取位置

    skip(InputStream, long)
    skip(Reader, long)
    skipFully(InputStream, long)
    skipFully(Reader, long)
    

    缓冲

    toBufferedInputStream(InputStream)
    toBufferedReader(Reader)
    

    转成字节/字符

    toByteArray(InputStream)
    toByteArray(InputStream, int)
    toByteArray(InputStream, long)
    toByteArray(Reader)
    toByteArray(Reader, String)
    toByteArray(Reader, Charset)
    toByteArray(String)
    toByteArray(URI)
    toByteArray(URL)
    toByteArray(URLConnection)
    toCharArray(InputStream)
    toCharArray(InputStream, String)
    toCharArray(InputStream, Charset)
    toCharArray(Reader)
    

    转成输入流

    toInputStream(CharSequence)
    toInputStream(CharSequence, String)
    toInputStream(CharSequence, Charset)
    toInputStream(String)
    toInputStream(String, String)
    toInputStream(String, Charset)
    

    toString

    toString(byte[])
    toString(byte[], String)
    toString(InputStream)
    toString(InputStream, String)
    toString(InputStream, Charset)
    toString(Reader)
    toString(URI)
    toString(URI, String)
    toString(URI, Charset)
    toString(URL)
    toString(URL, String)
    toString(URL, Charset)
    

    写入数据

    write(byte[], OutputStream)
    write(byte[], Writer)
    write(byte[], Writer, String)
    write(byte[], Writer, Charset)
    write(char[], OutputStream)
    write(char[], OutputStream, String)
    write(char[], OutputStream, Charset)
    write(char[], Writer)
    write(CharSequence, OutputStream)
    write(CharSequence, OutputStream, String)
    write(CharSequence, OutputStream, Charset)
    write(CharSequence, Writer)
    write(String, OutputStream)
    write(String, OutputStream, String)
    write(String, OutputStream, Charset)
    write(String, Writer)
    write(StringBuffer, OutputStream)
    write(StringBuffer, OutputStream, String)
    write(StringBuffer, Writer)
    writeLines(Collection<?>, String, OutputStream)
    writeLines(Collection<?>, String, OutputStream, String)
    writeLines(Collection<?>, String, OutputStream, Charset)
    writeLines(Collection<?>, String, Writer)
  • 相关阅读:
    Android服务器——TomCat服务器的搭建
    Ubuntu16.04 Liunx下同时安装Anaconda2与Anaconda3
    android中代码操作外部SD卡出错:W/System.err(1595): Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
    查准率与查全率(precision and recall) 的个人理解
    Python游戏-实现键盘控制功能
    UGUI世界坐标转换为UI本地坐标(游戏Hud的实现)
    LoadRunner中遭遇交互数据加密的处理方案
    [Java]链表的打印,反转与删除
    优化程序性能(3)——提高并行性
    基本排序算法的python实现
  • 原文地址:https://www.cnblogs.com/xiaozu/p/4555963.html
Copyright © 2011-2022 走看看