private void copy(StaplerRequest req, StaplerResponse rsp, File dir, URL src, String name) throws ServletException, IOException {
        try {
            FileUtils.copyURLToFile(src,new File(dir, name));
        } catch (IOException e) {
            LOGGER.log(Level.SEVERE, "Failed to copy "+name,e);
            sendError("Failed to copy "+name+": "+e.getMessage(),req,rsp);
            throw new AbortException();
        }
    }
private void copy ( StaplerRequest req , StaplerResponse rsp , File dir , URL src , String name ) throws ServletException , IOException { try { FileUtils . copyURLToFile ( src , new File ( dir , name ) ) ; } catch ( IOException e ) { LOGGER . log ( Level . SEVERE , "Failed to copy " + name , e ) ; sendError ( "Failed to copy " + name + ": " + e . getMessage ( ) , req , rsp ) ; throw new AbortException ( ) ; } }
Copies a single resource into the target folder, by the given name, and handle errors gracefully.