类 FileCopyUtils
java.lang.Object
cn.taketoday.util.FileCopyUtils
Simple utility methods for file and stream copying. All copy methods use a block size
of 4096 bytes, and close all affected streams when done. A variation of the copy
methods from this class that leave streams open can be found in
StreamUtils.
Mainly for use within the framework, but also useful for application code.
- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller, Hyunjin Choi, TODAY 2021/8/21 00:04
- 另请参阅:
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明private static voidAttempt to close the suppliedCloseable, silently swallowing any exceptions.static voidCopy the contents of the given byte array to the given output File.static voidcopy(byte[] in, OutputStream out) Copy the contents of the given byte array to the given OutputStream.static intCopy the contents of the given input File to the given output File.static intcopy(InputStream in, OutputStream out) Copy the contents of the given InputStream to the given OutputStream.static intCopy the contents of the given Reader to the given Writer.static intCopy the contents of the given Reader to the given Writer.static voidCopy the contents of the given String to the given Writer.static byte[]copyToByteArray(File in) Copy the contents of the given input File into a new byte array.static byte[]Copy the contents of the given InputStream into a new byte array.static StringcopyToString(Reader in) Copy the contents of the given Reader into a String.static StringcopyToString(Reader in, int bufferSize) Copy the contents of the given Reader into a String.
-
字段详细资料
-
BUFFER_SIZE
public static final int BUFFER_SIZEThe default buffer size used when copying bytes.- 另请参阅:
-
-
构造器详细资料
-
FileCopyUtils
public FileCopyUtils()
-
-
方法详细资料
-
copy
Copy the contents of the given input File to the given output File.- 参数:
in- the file to copy fromout- the file to copy to- 返回:
- the number of bytes copied
- 抛出:
IOException- in case of I/O errors
-
copy
Copy the contents of the given byte array to the given output File.- 参数:
in- the byte array to copy fromout- the file to copy to- 抛出:
IOException- in case of I/O errors
-
copyToByteArray
Copy the contents of the given input File into a new byte array.- 参数:
in- the file to copy from- 返回:
- the new byte array that has been copied to
- 抛出:
IOException- in case of I/O errors
-
copy
Copy the contents of the given InputStream to the given OutputStream. Closes both streams when done.- 参数:
in- the stream to copy fromout- the stream to copy to- 返回:
- the number of bytes copied
- 抛出:
IOException- in case of I/O errors
-
copy
Copy the contents of the given byte array to the given OutputStream. Closes the stream when done.- 参数:
in- the byte array to copy fromout- the OutputStream to copy to- 抛出:
IOException- in case of I/O errors
-
copyToByteArray
Copy the contents of the given InputStream into a new byte array. Closes the stream when done.- 参数:
in- the stream to copy from (may benullor empty)- 返回:
- the new byte array that has been copied to (possibly empty)
- 抛出:
IOException- in case of I/O errors
-
copy
Copy the contents of the given Reader to the given Writer. Closes both when done.- 参数:
in- the Reader to copy fromout- the Writer to copy to- 返回:
- the number of characters copied
- 抛出:
IOException- in case of I/O errors
-
copy
Copy the contents of the given Reader to the given Writer. Closes both when done.- 参数:
in- the Reader to copy fromout- the Writer to copy tobufferSize- user specified buffer size- 返回:
- the number of characters copied
- 抛出:
IOException- in case of I/O errors
-
copy
Copy the contents of the given String to the given Writer. Closes the writer when done.- 参数:
in- the String to copy fromout- the Writer to copy to- 抛出:
IOException- in case of I/O errors
-
copyToString
Copy the contents of the given Reader into a String. Closes the reader when done.- 参数:
in- the reader to copy from (may benullor empty)- 返回:
- the String that has been copied to (possibly empty)
- 抛出:
IOException- in case of I/O errors
-
copyToString
Copy the contents of the given Reader into a String. Closes the reader when done.- 参数:
in- the reader to copy from (may benullor empty)bufferSize- user specified buffer size- 返回:
- the String that has been copied to (possibly empty)
- 抛出:
IOException- in case of I/O errors
-
close
Attempt to close the suppliedCloseable, silently swallowing any exceptions.- 参数:
closeable- theCloseableto close
-