public Cache copyAs ( String source , String destination ) throws CacheException { if ( ! Strings . areValid ( source , destination ) ) { logger . error ( "invalid input parameters for copy from '{}' to '{}'" , source , destination ) ; throw new CacheException ( "invalid input parameters (source: '" + source + "', destination: '" + destination + "')" ) ; } try ( InputStream input = storage . retrieve ( source ) ; OutputStream output = storage . store ( destination ) ) { long copied = Streams . copy ( input , output ) ; logger . trace ( "copied {} bytes from '{}' to '{}'" , copied , source , destination ) ; } catch ( IOException e ) { logger . error ( "error copying from '" + source + "' to '" + destination + "'" , e ) ; throw new CacheException ( "error copying from '" + source + "' to '" + destination + "'" , e ) ; } return this ; }
Copies data from one resource to another possibly replacing the destination resource if one exists .