private static void copy(String source, String dest) throws UserInputErrorException { if (StringUtils.isEmpty(dest) || StringUtils.isEmpty(source)) throw new UserInputErrorException("dest or source cannot be null!! dest = " + dest + "/tsource=" + dest); File sourceFile = new File(source); if (!sourceFile.isFile()) throw new UserInputErrorException("source is not a file"); FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream(sourceFile); fos = new FileOutputStream(new File(dest)); byte[] bytes = new byte[4096]; int n = 0; while ((n = fis.read(bytes)) != -1) { fos.write(bytes, 0, n); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (fis != null) fis.close(); } catch (IOException e) { e.printStackTrace(); } try { if (fos != null) fos.close(); } catch (IOException e) { e.printStackTrace(); } } }