类 StreamUtils


  • public class StreamUtils
    extends Object
    Stream copying utilities
    作者:
    Steve Ebersole
    • 字段详细资料

      • DEFAULT_CHUNK_SIZE

        public static final int DEFAULT_CHUNK_SIZE
        Default size to use for reading buffers.
        另请参阅:
        常量字段值
    • 方法详细资料

      • copy

        public static long copy​(InputStream inputStream,
                                OutputStream outputStream)
                         throws IOException
        Copy the inputStream to the outputStream. Uses a buffer of the default size (DEFAULT_CHUNK_SIZE).
        参数:
        inputStream - The input stream to read
        outputStream - The output stream to write to
        返回:
        The number of bytes read
        抛出:
        IOException - If a problem occurred accessing either stream
      • copy

        public static long copy​(InputStream inputStream,
                                OutputStream outputStream,
                                int bufferSize)
                         throws IOException
        Copy the inputStream to the outputStream using a buffer of the specified size
        参数:
        inputStream - The input stream to read
        outputStream - The output stream to write to
        bufferSize - The size of the buffer to use for reading
        返回:
        The number of bytes read
        抛出:
        IOException - If a problem occurred accessing either stream
      • copy

        public static long copy​(Reader reader,
                                Writer writer)
                         throws IOException
        Copy the reader to the writer. Uses a buffer of the default size (DEFAULT_CHUNK_SIZE).
        参数:
        reader - The reader to read from
        writer - The writer to write to
        返回:
        The number of bytes read
        抛出:
        IOException - If a problem occurred accessing reader or writer
      • copy

        public static long copy​(Reader reader,
                                Writer writer,
                                int bufferSize)
                         throws IOException
        Copy the reader to the writer using a buffer of the specified size
        参数:
        reader - The reader to read from
        writer - The writer to write to
        bufferSize - The size of the buffer to use for reading
        返回:
        The number of bytes read
        抛出:
        IOException - If a problem occurred accessing either stream