org.springframework.util
Class FileCopyUtils


public abstract class FileCopyUtils

Utility methods for file and stream copying. Mainly for use within the framework.

Author:
Juergen Hoeller
Since: 06.10.2003

Field Summary
 final static intBLOCK_SIZE
           

Method Summary
 static voidcopy(Reader in, Writer out)
          Copy the contents of the given InputStream to the given OutputStream.
 static voidcopy(InputStream in, OutputStream out)
          Copy the contents of the given InputStream to the given OutputStream.
 static voidcopy(File in, File out)
          Copy the contents of the given input File to the given output File.
 static voidcopy(byte[] in, File out)
          Copy the contents of the given byte array to the given output File.
 static byte[]copyToByteArray(InputStream in)
          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.

Field Detail

BLOCK_SIZE

public final static int BLOCK_SIZE
Method Detail

copy

public static void copy(Reader in, Writer out)
throws java.io.IOException
Copy 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
Throws:
IOException - in case of I/O errors

copy

public static void copy(InputStream in, OutputStream out)
throws java.io.IOException
Copy 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
Throws:
IOException - in case of I/O errors

copy

public static void copy(File in, File out)
throws java.io.IOException
Copy 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
Throws:
IOException - in case of I/O errors

copy

public static void copy(byte[] in, File out)
throws java.io.IOException
Copy 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

copyToByteArray

public static byte[] copyToByteArray(InputStream in)
throws java.io.IOException
Copy the contents of the given InputStream into a new byte array.
Parameters:
in - the stream to copy from
Returns: the new byte array that has been copied to
Throws:
IOException - in case of I/O errors

copyToByteArray

public static byte[] copyToByteArray(File in)
throws java.io.IOException
Copy 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