code: public CmsFile readFile(CmsDbContext dbc, CmsResource resource) throws CmsException {
  
          if (resource.isFolder()) {
              throw new CmsVfsResourceNotFoundException(
                  Messages.get().container(
                      Messages.ERR_ACCESS_FOLDER_AS_FILE_1,
                      dbc.removeSiteRoot(resource.getRootPath())));
          }
  
          CmsUUID projectId = dbc.currentProject().getUuid();
          CmsFile file = null;
          if (resource instanceof I_CmsHistoryResource) {
              file = new CmsHistoryFile((I_CmsHistoryResource)resource);
              file.setContents(
                  getHistoryDriver(dbc).readContent(
                      dbc,
                      resource.getResourceId(),
                      ((I_CmsHistoryResource)resource).getPublishTag()));
          } else {
              file = new CmsFile(resource);
              file.setContents(getVfsDriver(dbc).readContent(dbc, projectId, resource.getResourceId()));
          }
          return file;
      }
docs: Reads a file resource (including it's binary content) from the VFS,
  using the specified resource filter.<p>
  
  In case you do not need the file content,
  use <code>{@link #readResource(CmsDbContext, String, CmsResourceFilter)}</code> instead.<p>
  
  The specified filter controls what kind of resources should be "found"
  during the read operation. This will depend on the application. For example,
  using <code>{@link CmsResourceFilter#DEFAULT}</code> will only return currently
  "valid" resources, while using <code>{@link CmsResourceFilter#IGNORE_EXPIRATION}</code>
  will ignore the date release / date expired information of the resource.<p>
  
  @param dbc the current database context
  @param resource the base file resource (without content)
  @return the file read from the VFS
  @throws CmsException if operation was not successful