Class FileSystemUtils

java.lang.Object
com.ptc.windchill.vfs.FileSystemUtils

public final class FileSystemUtils extends Object
Utility class for working with virtual file systems

Windchill+ customization code should use this class to obtain an instance of java.nio.file.FileSystem for I/O. This file system will be backed by cloud storage (an Azure Storage Container - subject to change).

Supported file systems are:

  1. VFS

Example implementation:

 import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.file.DirectoryStream;
 import java.nio.file.FileSystem;
 import java.nio.file.FileSystems;
 import java.nio.file.Path;
 import java.util.Date;

 import com.ptc.windchill.vfs.FileSystemUtils;

 FileSystem vfs = FileSystemUtils.getFileSystem(FileSystemUtils.SupportedFileSystems.VFS);

 // directory list
 Path folderPath = vfs.getPath("sample-folder1");
 try (DirectoryStream directoryStream = Files.newDirectoryStream(folderPath)) {
     for (Path filePath : directoryStream) {
         System.out.println(filePath.getFileName());
     }
 }

 // read file
 Path filePath = vfs.getPath("sample-folder1/sample-file1.txt");
 try (InputStream is = Files.newInputStream(filePath)) {
     System.out.println(new String(is.readAllBytes(), "UTF-8"));
 }

 // create / update file
 Path anotherFilepath = vfs.getPath("sample-folder1/new-file.txt");
 try (OutputStream os = Files.newOutputStream(anotherFilePath)) {
     os.write(new Date().toString().getBytes("UTF-8"));
 }

 // delete file
 Files.delete(anotherFilePath);
 

Supported API: true
Extendable: false