- FileUtils.copyURLToFile(ldif.getURL(), new File(configuration
- .getLdifDirectory().getAbsolutePath()
- + File.separator + ldif.getFilename().replace(':', '_')));
- if (log.isDebugEnabled())
- log.debug("Copied " + ldif + " to LDIF directory "
- + configuration.getLdifDirectory());
+ File targetFile = new File(configuration.getLdifDirectory()
+ .getAbsolutePath()
+ + File.separator + ldif.getFilename().replace(':', '_'));
+ OutputStream output = null;
+ try {
+ output = new FileOutputStream(targetFile);
+ IOUtils.copy(ldif.getInputStream(), output);
+ if (log.isDebugEnabled())
+ log.debug("Copied " + ldif + " to LDIF directory "
+ + configuration.getLdifDirectory());
+ } finally {
+ IOUtils.closeQuietly(output);
+ }