/** * gets a file from server and copy it local * * @return FTPCLient * @throws PageException * @throws IOException */ private AFTPClient actionGetFile() throws PageException, IOException { required("remotefile", remotefile); required("localfile", localfile); AFTPClient client = getClient(); Resource local = ResourceUtil.toResourceExistingParent(pageContext, localfile); // new File(localfile); pageContext.getConfig().getSecurityManager().checkFileLocation(local); if (failifexists && local.exists()) throw new ApplicationException( "File [" + local + "] already exist, if you want to overwrite, set attribute failIfExists to false"); OutputStream fos = null; client.setFileType(getType(local)); boolean success = false; try { fos = IOUtil.toBufferedOutputStream(local.getOutputStream()); success = client.retrieveFile(remotefile, fos); } finally { IOUtil.closeEL(fos); if (!success) local.delete(); } writeCfftp(client); return client; }