Example 2

Copy the file f to a future entity in a subdirectory under the directory d. All nonexisting parent directories will be created.

JavaScript

new CopyTF(). setSource(f). setTarget( new FutureFile(d, new RelativeLocation("d1/d2/f"))).run();

Example 3

Copy the file f to the directory d, represented as a FutureDirectory (this does exactly the same as example 1)

JavaScript

new CopyTF(). setSource(f). setTarget( new FutureDirectory(d)).run();

Example 4

Copy the directory src to the directory d. No child entities in src will be copied. (This is just a lengthy way of creating src in d.)

JavaScript

new CopyTF(). setSource(src). setTarget(d).run();

Example 5

Copy all files from the directory hierarchy under d to the directory flat_d. (See ErrorIgnoringTF for a similar example.)

JavaScript

new RecursiveActionTF(). setSource(d). setTaskFactory( new CopyTF(). setOverwrite(true). setTarget(flat_d)).run();

Example 6

Copy the contents of the URL http://www.vecka.nu/ to the file vecka.html in the directory d.

JavaScript

new CopyTF(). setSource( // Have to name the file manually since the URL lacks a file part. If we had // fetched a named page (such as index.html), we would not have to set a // name manually (although we could, if we wanted). new NamedReadableFileAdapter( new UrlReadableFile( new URL("http://www.vecka.nu/")), "vecka.html")). setTarget(d).run();

Example 7

Create a property file with information about the current build. The file is created in the bin/org/example directory. This can for instance be used by an application to publish information on how it was built.

JavaScript

new CopyTF(). setSource( new ManualNamedReadableFile( "build.properties", "# Build properties \n" + "timestamp=" + new Date().getTime() + "\n" + "user=" + Packages.java.lang.System.getProperty("user.name"))). setTarget( new FutureFile( bin, new RelativeLocation("org/example/build.properties"))).run();

Example 8

Copy the files f1 and f2 to the directory d. The files may be EntityFS EFile:s or Java File:s. d may be an EntityFS Directory or a Java File directory.

JavaScript

new CopyTF(). addSource(f1). addSource(f2). setTarget(d).run();


* An EntityFS-aware task is implemented using EntityFS. This means that it uses the filter settings of DirectoryView:s and also that it often can work with other file system implementations than File-based, such as the RAM file system.