Class FileCopyUtils
java.lang.Object
org.springframework.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.
- Since:
- 06.10.2003
- Author:
- Juergen Hoeller, Hyunjin Choi
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intThe default buffer size used when copying bytes.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic 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 voidCopy the contents of the given String to the given Writer.static byte[]Copy the contents of the given InputStream into a new byte array.static byte[]copyToByteArray(File in) Copy the contents of the given input File into a new byte array.static StringCopy the contents of the given Reader into a String.
- 
Field Details- 
BUFFER_SIZEpublic static final int BUFFER_SIZEThe default buffer size used when copying bytes.- See Also:
 
 
- 
- 
Constructor Details- 
FileCopyUtilspublic FileCopyUtils()
 
- 
- 
Method Details- 
copyCopy the contents of the given input File to the given output File.- Parameters:
- in- the file to copy from
- out- the file to copy to
- Returns:
- the number of bytes copied
- Throws:
- IOException- in case of I/O errors
 
- 
copyCopy the contents of the given byte array to the given output File.- Parameters:
- in- the byte array to copy from
- out- the file to copy to
- Throws:
- IOException- in case of I/O errors
 
- 
copyToByteArrayCopy the contents of the given input File into a new byte array.- Parameters:
- in- the file to copy from
- Returns:
- the new byte array that has been copied to
- Throws:
- IOException- in case of I/O errors
 
- 
copyCopy the contents of the given InputStream to the given OutputStream. Closes both streams when done.- Parameters:
- in- the stream to copy from
- out- the stream to copy to
- Returns:
- the number of bytes copied
- Throws:
- IOException- in case of I/O errors
 
- 
copyCopy the contents of the given byte array to the given OutputStream. Closes the stream when done.- Parameters:
- in- the byte array to copy from
- out- the OutputStream to copy to
- Throws:
- IOException- in case of I/O errors
 
- 
copyToByteArrayCopy the contents of the given InputStream into a new byte array. Closes the stream when done.- Parameters:
- in- the stream to copy from (may be- nullor empty)
- Returns:
- the new byte array that has been copied to (possibly empty)
- Throws:
- IOException- in case of I/O errors
 
- 
copyCopy the contents of the given Reader to the given Writer. Closes both when done.- Parameters:
- in- the Reader to copy from
- out- the Writer to copy to
- Returns:
- the number of characters copied
- Throws:
- IOException- in case of I/O errors
 
- 
copyCopy the contents of the given String to the given Writer. Closes the writer when done.- Parameters:
- in- the String to copy from
- out- the Writer to copy to
- Throws:
- IOException- in case of I/O errors
 
- 
copyToStringCopy the contents of the given Reader into a String. Closes the reader when done.- Parameters:
- in- the reader to copy from (may be- nullor empty)
- Returns:
- the String that has been copied to (possibly empty)
- Throws:
- IOException- in case of I/O errors
 
 
-