mirror of https://github.com/apache/activemq.git
Added copy file method
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@632961 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c427689dad
commit
d8b407bb63
|
@ -17,7 +17,12 @@
|
|||
package org.apache.activemq.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* @version $Revision$
|
||||
|
@ -25,6 +30,7 @@ import java.io.IOException;
|
|||
public final class IOHelper {
|
||||
protected static final int MAX_DIR_NAME_LENGTH;
|
||||
protected static final int MAX_FILE_NAME_LENGTH;
|
||||
private static final int DEFAULT_BUFFER_SIZE = 4096;
|
||||
private IOHelper() {
|
||||
}
|
||||
|
||||
|
@ -143,6 +149,23 @@ public final class IOHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static void copyFile(File src, File dest) throws IOException {
|
||||
FileInputStream fileSrc = new FileInputStream(src);
|
||||
FileOutputStream fileDest = new FileOutputStream(dest);
|
||||
copyInputStream(fileSrc, fileDest);
|
||||
}
|
||||
|
||||
public static void copyInputStream(InputStream in, OutputStream out) throws IOException {
|
||||
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
|
||||
int len = in.read(buffer);
|
||||
while (len >= 0) {
|
||||
out.write(buffer, 0, len);
|
||||
len = in.read(buffer);
|
||||
}
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
|
||||
static {
|
||||
MAX_DIR_NAME_LENGTH = Integer.valueOf(System.getProperty("MaximumDirNameLength","200")).intValue();
|
||||
MAX_FILE_NAME_LENGTH = Integer.valueOf(System.getProperty("MaximumFileNameLength","64")).intValue();
|
||||
|
|
Loading…
Reference in New Issue