This sample uses the CopyFileVisitor to recursively copy a source directory to a target directory. The CopyFileVisitor implements the FileVisitor interface and thus can be use with one of the Files.walkFileTree methods. For convenience there is the static CopyFileVisitor.copy method.
cd docs/samples/dist java -cp softsmithy-lib-samples-0.2.jar:lib/softsmithy-lib-core-0.2.jar samples.nio.file.CopyFilesSample data/first output
Oracle's Java SE 7 Runtime comes with a FileSystemProvider implementation for JAR and ZIP files. This FileSystemProvider allows you to work with JAR and ZIP files in a similar way as with the local file system.
cd docs/samples/dist java -cp softsmithy-lib-samples-0.2.jar:lib/softsmithy-lib-core-0.2.jar samples.nio.file.ExtractJarResourceSample output
This sample is similar to Extract resources from a JAR, but adds resources to a ZIP file instead of extracting resources from a JAR.
cd docs/samples/dist java -cp softsmithy-lib-samples-0.2.jar:lib/softsmithy-lib-core-0.2.jar samples.nio.file.AddZipResourceSample data/sample-data.zip output data/another /first
<install-dir>/docs/samples/dist/softsmithy-lib-samples-0.2.jar <install-dir>/docs/samples/dist/lib/<other jars>Below is the code from GetInstallationDirSample.java that gets the <install-dir>.
In this sample, JarFiles.getJarURI is used to get the installation directory.
cd docs/samples/dist java -cp softsmithy-lib-samples-0.2.jar:lib/softsmithy-lib-core-0.2.jar samples.nio.file.GetInstallationDirSample