### Virtual File System (VFS) code examples

The virtial file system allows the same operations as you are may know form java.io but names and behavior is a bit different.

- Find a file or folder vfs style: If you are shure it is a folder you can resolve and cast it immediatly

      VFSContainer folder = (VFSContainer) wikiContainer.resolve(WIKI_FOLDER_NAME);

  if you are not shure whether it is a file or a folder you get an VFSItem as result of a resolve operatin and have to check with:

      if (item instanceof VFSLeaf) {
      VFSLeaf leaf = (VFSLeaf)item;

- Get a folder in the OLAT bcroot/repository hierarchie:

      VFSContainer rootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(ores);

- To write of read from a vfs file you have to get the OutputStream from the leave where your can read of write with support of the FileUtils class:

      VFSLeaf leaf = wikiContentContainer.createChildLeaf(filename);
      FileUtils.save(leaf.getOutputStream(false), content, "utf-8");