apache-comnons系列之commons-io-2.5 org.apache.commons.io.IOUtils學習筆記
概述
- OutputStream、InputStream、Writer、Reader學習筆記
- http://blog.csdn.net/undergrowth/article/details/43820639
- 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
- This class provides static utility methods for input/output operations.
測試
- org.apache.commons.io.IOUtilsTestCase
- closeQuietly
- Closes an
unconditionallyOutputStream
- Equivalent to {@link OutputStream#close()}, except any exceptions will be ignored
- This is typically used in finally blocks
- 借助于closeable.close()關閉源
- Closes an
- toByteArray
- 依賴copy
- copy
- 依賴copyLarge,copyLarge以4k為一組複制資料
- Large streams (over 2GB) will return a bytes copied value of
after the copy has completed since the correct number of bytes cannot be returned as an int-1
- readLines
- This method buffers the input internally, so there is no need to use a
.BufferedInputStream
- This method buffers the input internally, so there is no need to use a
- contentEquals
- Compares the contents of two Streams to determine if they are equal or not.
- This method buffers the input internally using
if they are not already buffered.BufferedInputStream
- 一個byte一個byte比較/位元組和字元