类 IOUtils

java.lang.Object
com.alibaba.cloud.commons.io.IOUtils

public final class IOUtils extends Object
The IOUtils. copy from apache commons-io.
作者:
theonefx
  • 字段详细资料

    • EOF

      public static final int EOF
      Represents the end-of-file (or stream).
      从以下版本开始:
      2.5 (made public)
      另请参阅:
  • 方法详细资料

    • toString

      public static String toString(InputStream input, Charset encoding) throws IOException
      Gets the contents of an InputStream as a String using the specified character encoding.

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

      参数:
      input - the InputStream to read from
      encoding - the encoding to use, null means platform default
      返回:
      the requested String
      抛出:
      NullPointerException - if the input is null
      IOException - if an I/O error occurs
      从以下版本开始:
      2.3
    • copy

      public static int copy(Reader input, Writer output) throws IOException
      Copies 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, or -1 if > Integer.MAX_VALUE
      抛出:
      NullPointerException - if the input or output is null
      IOException - if an I/O error occurs
      从以下版本开始:
      1.1
    • copy

      public static void copy(InputStream input, Writer output, Charset inputEncoding) throws IOException
      Copies bytes from an InputStream to chars on a Writer using the specified character encoding.

      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
      inputEncoding - the encoding to use for the input stream, null means platform default
      抛出:
      NullPointerException - if the input or output is null
      IOException - if an I/O error occurs
      从以下版本开始:
      2.3
    • copy

      public static long copy(InputStream input, OutputStream output, int bufferSize) throws IOException
      Copies bytes from an InputStream to an OutputStream using an internal buffer of the given size.

      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
      bufferSize - the bufferSize used to copy from the input to the output
      返回:
      the number of bytes copied
      抛出:
      NullPointerException - if the input or output is null
      IOException - if an I/O error occurs
      从以下版本开始:
      2.5
    • copyLarge

      public static long copyLarge(Reader input, Writer output) throws IOException
      Copies 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.

      The buffer size is given by DEFAULT_BUFFER_SIZE.

      参数:
      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
      从以下版本开始:
      1.3
    • copyLarge

      public static long copyLarge(Reader input, Writer output, char[] buffer) throws IOException
      Copies chars from a large (over 2GB) Reader to a Writer.

      This method uses the provided buffer, so there is no need to use a BufferedReader.

      参数:
      input - the Reader to read from
      output - the Writer to write to
      buffer - the buffer to be used for the copy
      返回:
      the number of characters copied
      抛出:
      NullPointerException - if the input or output is null
      IOException - if an I/O error occurs
      从以下版本开始:
      2.2
    • copyLarge

      public static long copyLarge(InputStream input, OutputStream output) throws IOException
      Copies 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.

      The buffer size is given by DEFAULT_BUFFER_SIZE.

      参数:
      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
      从以下版本开始:
      1.3
    • copyLarge

      public static long copyLarge(InputStream input, OutputStream output, byte[] buffer) throws IOException
      Copies bytes from a large (over 2GB) InputStream to an OutputStream.

      This method uses the provided buffer, so there is no need to use a BufferedInputStream.

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