Here you can find the source of copyFiles(String srcFilePath, String destFilePath)
Parameter | Description |
---|---|
srcFilePath | a parameter |
destFilePath | a parameter |
Parameter | Description |
---|---|
IOException | in case some problems occured |
public static void copyFiles(String srcFilePath, String destFilePath) throws IOException
//package com.java2s; // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { /**//from ww w.j a v a 2 s .c o m * */ private static final int COPY_BUF_SIZE = 512; /** * This method is used for coping file from one place to the other. * * @param srcFilePath * @param destFilePath * @throws IOException * @throws IOException in case some problems occured */ public static void copyFiles(String srcFilePath, String destFilePath) throws IOException { FileInputStream input = null; FileOutputStream output = null; try { input = new FileInputStream(srcFilePath); output = new FileOutputStream(destFilePath); copyStreams(input, output); } finally { if (input != null) { input.close(); } if (output != null) { output.close(); } } } /** * copy is to os. * * @param is * @param os * @throws IOException thrown if copy fails */ public static void copyStreams(InputStream is, OutputStream os) throws IOException { byte[] bytearray = new byte[COPY_BUF_SIZE]; int len = 0; while ((len = is.read(bytearray)) != -1) { os.write(bytearray, 0, len); } } }