commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Ivankovits <ma...@ops.co.at>
Subject Re: VFS Questions
Date Tue, 03 Jan 2006 08:39:43 GMT
Hi!

I am back from vacation now, so lets start ...

>   ad 4.: rename:
>            long lastModTime = 
> sourceFileObject.getContent().getLastModifiedTime();
>            if (!sourceFileObject.canRenameTo(targetFileObject)){ // 
> other device
>                targetFileObject.copyFrom(sourceFileObject, 
> Selectors.SELECT_SELF);
>                sourceFileObject.delete(Selectors.SELECT_SELF);
>             } else { // same device
>                sourceFileObject.moveTo(targetFileObject);
>            }
>            
> targetFileObject.getContent().setLastModifiedTime(lastModTime);
Its sufficient to call moveTo in either case, moveTo will already handle 
the different filesystem case and get/set the lastModifiedTime if 
supported by the filesystem.

So:
sourceFileObject.moveTo(targetFileObject);

do the job.


Ciao,
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message