Hi I want to copy a file from 1 directory to another, but the date has to be the same. so when the last modified date in the fromdirectory is 14:35, I want it to be the same in the todirectory.
How can I do this using groovy?
new AntBuilder().copy ( file : 'path/to/source',
tofile : 'path/to/destination',
preservelastmodified : 'true' )
def source = new File ('path/to/source')
def destination = new File ('path/to/destination')
source.withInputStream { is ->
destination << is
}
destination.lastModified = source.lastModified()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With