Package com.ptc.windchill.vfs
Class FileSystemUtils
java.lang.Object
com.ptc.windchill.vfs.FileSystemUtils
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:
Supported API: true
Extendable: false
- VFS
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic FileSystemgetVirtualFileSystem(FileSystemUtils.SupportedFileSystems supportedFileSystem) Fetches a java.nio.file.FileSystem backed by cloud storage (Azure storage container)
-
Method Details
-
getVirtualFileSystem
public static FileSystem getVirtualFileSystem(FileSystemUtils.SupportedFileSystems supportedFileSystem) throws IOException, URISyntaxException Fetches a java.nio.file.FileSystem backed by cloud storage (Azure storage container) Refer javadoc of classFileSystemUtilsfor a sample implementation- Parameters:
supportedFileSystem- Enum value from SupportedFileSystems- Returns:
- java.nio.file.FileSystem implementation
- Throws:
IOExceptionURISyntaxException-
Supported API: true
Extendable: false
-