com.baidu.driver4j.bns
类 IOUtils

java.lang.Object
  继承者 com.baidu.driver4j.bns.IOUtils

public class IOUtils
extends Object

IN/OUT utility class

从以下版本开始:
1.0.0
作者:
xiemalin

构造方法摘要
IOUtils()
           
 
方法摘要
static int copy(InputStream input, OutputStream output)
          Copy bytes from an InputStream to an OutputStream.
static void copy(InputStream input, Writer output)
          Copy bytes from an InputStream to chars on a Writer using the default character encoding of the platform.
static int copy(Reader input, Writer output)
          Copy chars from a Reader to a Writer.
static long copyLarge(InputStream input, OutputStream output)
          Copy bytes from a large (over 2GB) InputStream to an OutputStream.
static long copyLarge(Reader input, Writer output)
          Copy chars from a large (over 2GB) Reader to a Writer.
static byte[] toByteArray(InputStream input)
          Get the contents of an InputStream as a byte[].
static String toString(InputStream input)
          Get the contents of an InputStream as a String using the default character encoding of the platform.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

IOUtils

public IOUtils()
方法详细信息

toByteArray

public static byte[] toByteArray(InputStream input)
                          throws IOException
Get the contents of an InputStream as a byte[].

This method buffers the input internally, so there is no need to use a BufferedInputStream.

参数:
input - the InputStream to read from
返回:
the requested byte array
抛出:
NullPointerException - if the input is null
IOException - if an I/O error occurs

copy

public static int copy(InputStream input,
                       OutputStream output)
                throws IOException
Copy bytes from an InputStream to an OutputStream.

This method buffers the input internally, so there is no need to use a BufferedInputStream.

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. For large streams use the copyLarge(InputStream, OutputStream) method.

参数:
input - the InputStream to read from
output - the OutputStream to write to
返回:
the number of bytes copied
抛出:
NullPointerException - if the input or output is null
IOException - if an I/O error occurs
ArithmeticException - if the byte count is too large
从以下版本开始:
Commons IO 1.1

copyLarge

public static long copyLarge(InputStream input,
                             OutputStream output)
                      throws IOException
Copy bytes from a large (over 2GB) InputStream to an OutputStream.

This method buffers the input internally, so there is no need to use a BufferedInputStream.

参数:
input - the InputStream to read from
output - the OutputStream to write to
返回:
the number of bytes copied
抛出:
NullPointerException - if the input or output is null
IOException - if an I/O error occurs
从以下版本开始:
Commons IO 1.3

toString

public static String toString(InputStream input)
                       throws IOException
Get the contents of an InputStream as a String using the default character encoding of the platform.

This method buffers the input internally, so there is no need to use a BufferedInputStream.

参数:
input - the InputStream to read from
返回:
the requested String
抛出:
NullPointerException - if the input is null
IOException - if an I/O error occurs

copy

public static void copy(InputStream input,
                        Writer output)
                 throws IOException
Copy bytes from an InputStream to chars on a Writer using the default character encoding of the platform.

This method buffers the input internally, so there is no need to use a BufferedInputStream.

This method uses InputStreamReader.

参数:
input - the InputStream to read from
output - the Writer to write to
抛出:
NullPointerException - if the input or output is null
IOException - if an I/O error occurs
从以下版本开始:
Commons IO 1.1

copy

public static int copy(Reader input,
                       Writer output)
                throws IOException
Copy chars from a Reader to a Writer.

This method buffers the input internally, so there is no need to use a BufferedReader.

Large streams (over 2GB) will return a chars copied value of -1 after the copy has completed since the correct number of chars cannot be returned as an int. For large streams use the copyLarge(Reader, Writer) method.

参数:
input - the Reader to read from
output - the Writer to write to
返回:
the number of characters copied
抛出:
NullPointerException - if the input or output is null
IOException - if an I/O error occurs
ArithmeticException - if the character count is too large
从以下版本开始:
Commons IO 1.1

copyLarge

public static long copyLarge(Reader input,
                             Writer output)
                      throws IOException
Copy chars from a large (over 2GB) Reader to a Writer.

This method buffers the input internally, so there is no need to use a BufferedReader.

参数:
input - the Reader to read from
output - the Writer to write to
返回:
the number of characters copied
抛出:
NullPointerException - if the input or output is null
IOException - if an I/O error occurs
从以下版本开始:
Commons IO 1.3


Copyright © 2016. All rights reserved.