Here you can find the source of copyFiles(String strPath, String dstPath, String srcExtension)
public static void copyFiles(String strPath, String dstPath, String srcExtension) throws IOException
//package com.java2s; /*L/*from www . j ava2 s . c o m*/ * Copyright SAIC, SAIC-Frederick. * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/caadapter/LICENSE.txt for details. */ import java.io.*; public class Main { public static void copyFiles(String strPath, String dstPath, String srcExtension) throws IOException { // if I remove all condition then it throws exception which I wrote below /* if ((src.getName().equals("admin")) || (src.getParentFile().getParentFile().getName().equals("presentation")) || (src.getName().equals("cashteam")) && (src.isDirectory())) ; // Do not copy anything under this. elseif (src.isDirectory()) */ File src = new File(strPath); File dest = new File(dstPath); if (src.isDirectory()) { //if(dest.exists()!=true) dest.mkdirs(); String list[] = src.list(); for (int i = 0; i < list.length; i++) { String dest1 = dest.getAbsolutePath() + "\\" + list[i]; String src1 = src.getAbsolutePath() + "\\" + list[i]; copyFiles(src1, dest1, srcExtension); } } else if (strPath == null || strPath.endsWith(srcExtension)) { FileInputStream fin = new FileInputStream(src); FileOutputStream fout = new FileOutputStream(dest); int c; while ((c = fin.read()) >= 0) fout.write(c); fin.close(); fout.close(); } } }