apache-comnons系列之commons-io-2.5 org.apache.commons.io.IOUtils学习笔记

58 篇文章 0 订阅
53 篇文章 1 订阅

apache-comnons系列之commons-io-2.5 org.apache.commons.io.IOUtils学习笔记

概述

  • OutputStream、InputStream、Writer、Reader学习笔记
  • General IO stream manipulation utilities.
    • This class provides static utility methods for input/output operations.
      • 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
    • byte-to-char methods and char-to-byte methods
      • default encoding and encoding
    • buffered internally
      • default buffer size of 4K

测试

  • org.apache.commons.io.IOUtilsTestCase
  • closeQuietly
    • Closes an OutputStream unconditionally
    • Equivalent to {@link OutputStream#close()}, except any exceptions will be ignored
    • This is typically used in finally blocks
    • 借助于closeable.close()关闭源
  • toByteArray
    • 依赖copy
  • copy
    • 依赖copyLarge,copyLarge以4k为一组复制数据
    • Large streams (over 2GB) will return a bytes copied value of -1 after the copy has completed since the correct number of bytes cannot be returned as an int
  • readLines
    • This method buffers the input internally, so there is no need to use a BufferedInputStream.
  • contentEquals
    • Compares the contents of two Streams to determine if they are equal or not.
    • This method buffers the input internally using BufferedInputStream if they are not already buffered.
    • 一个byte一个byte比较/字节和字符
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值