public static void copyFileAndRename(File srcFile, File destFile) throws IOException {
if (!destFile.exists()) {
destFile.mkdir();
}
File[] listFiles = srcFile.listFiles();
for (File file : listFiles) {
if (file.getName().endsWith(".txt")) {
String name = file.getName();
File fi = new File(destFile, name);
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fi));
byte[] byt = new byte[1024];
int len = 0;
while ((len = bis.read(byt)) != -1) {
bos.write(byt, 0, len);
}
bis.close();
bos.close();