當前位置: 首頁>>代碼示例>>Java>>正文


Java FileObject.createFolder方法代碼示例

本文整理匯總了Java中org.apache.commons.vfs2.FileObject.createFolder方法的典型用法代碼示例。如果您正苦於以下問題:Java FileObject.createFolder方法的具體用法?Java FileObject.createFolder怎麽用?Java FileObject.createFolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.vfs2.FileObject的用法示例。


在下文中一共展示了FileObject.createFolder方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: moveFileWithPattern

import org.apache.commons.vfs2.FileObject; //導入方法依賴的package包/類
/**
 * @param remoteFile     Location of the file
 * @param destination    New file location
 * @param filePattern    Pattern of the file
 * @param manager        Standard file system manager
 * @param messageContext The message context that is generated for processing the file
 * @throws IOException
 */
private void moveFileWithPattern(FileObject remoteFile, String destination, String filePattern,
                                 StandardFileSystemManager manager, MessageContext messageContext) throws IOException {
    FilePattenMatcher patternMatcher = new FilePattenMatcher(filePattern);
    try {
        if (patternMatcher.validate(remoteFile.getName().getBaseName())) {
            FileObject file = manager.resolveFile(destination, FileConnectorUtils.init(messageContext));
            if (!file.exists()) {
                file.createFolder();
            }
            file = manager.resolveFile(destination + File.separator + remoteFile.getName().getBaseName(),
                    FileConnectorUtils.init(messageContext));
            remoteFile.moveTo(file);
        }
    } catch (IOException e) {
        log.error("Error occurred while moving a file. " + e.getMessage(), e);
    }
}
 
開發者ID:wso2-extensions,項目名稱:esb-connector-file,代碼行數:26,代碼來源:FileMove.java

示例2: save

import org.apache.commons.vfs2.FileObject; //導入方法依賴的package包/類
@Override
public synchronized void save(Note note) throws IOException {
  GsonBuilder gsonBuilder = new GsonBuilder();
  gsonBuilder.setPrettyPrinting();
  Gson gson = gsonBuilder.create();
  String json = gson.toJson(note);

  FileObject rootDir = getRootDir();

  FileObject noteDir = rootDir.resolveFile(note.id(), NameScope.CHILD);

  if (!noteDir.exists()) {
    noteDir.createFolder();
  }
  if (!isDirectory(noteDir)) {
    throw new IOException(noteDir.getName().toString() + " is not a directory");
  }

  FileObject noteJson = noteDir.resolveFile(".note.json", NameScope.CHILD);
  // false means not appending. creates file if not exists
  OutputStream out = noteJson.getContent().getOutputStream(false);
  out.write(json.getBytes(conf.getString(ConfVars.ZEPPELIN_ENCODING)));
  out.close();
  noteJson.moveTo(noteDir.resolveFile("note.json", NameScope.CHILD));
}
 
開發者ID:lorthos,項目名稱:incubator-zeppelin-druid,代碼行數:26,代碼來源:VFSNotebookRepo.java

示例3: saveToTargetLocation

import org.apache.commons.vfs2.FileObject; //導入方法依賴的package包/類
@Override
public void saveToTargetLocation(File tmpFile, String targetDir) throws FileSystemException, IOException {
    if (tmpFile == null)
        throw new NullPointerException("tmpFile cannot be null");

    if (!tmpFile.exists())
        throw new FileNotFoundException(
            "Unable to save file '" + tmpFile.getAbsolutePath() + "' to target location as it does not exist");

    FileObject tmpFO = null;
    FileObject targetDirFO = null;
    FileObject targetFileFO = null;

    try {
        FileSystemManager fsManager = fileSystemManager();

        // Tmp file.
        tmpFO = fsManager.resolveFile(tmpFile.getAbsolutePath());

        // Where to copy tmp file to.
        targetDirFO = get(targetDir);
        targetFileFO = get(new File(targetDir, tmpFile.getName()).getAbsolutePath());

        // Attempt to create directories if they do not exist.
        if (!targetDirFO.exists())
            targetDirFO.createFolder();

        if (targetDirFO.exists()) {
            log.info("Saving file'" + tmpFO.getURL() + "' to '" + targetFileFO.getURL() + "'.");

            targetFileFO.copyFrom(tmpFO, Selectors.SELECT_SELF);
        } else {
            throw new FileSystemException(
                "Attempt to create target dir '" + targetDirFO.getURL().toString() + "' failed");
        }

        if (targetDirFO == null || !targetDirFO.exists())
            throw new FileSystemException("Tmp file '" + tmpFO.getURL()
                + "' could not be copied to target locaton '" + targetFileFO.getURL() + "'");
    } finally {
        close(tmpFO);
        close(targetDirFO);
        close(targetFileFO);
    }
}
 
開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:46,代碼來源:DefaultVfsHelper.java

示例4: init

import org.apache.commons.vfs2.FileObject; //導入方法依賴的package包/類
@Override
public void init(String storeId) {
    super.init(storeId);

    uri = MCRConfiguration.instance().getString(storeConfigPrefix + "URI");
    String check = MCRConfiguration.instance().getString(storeConfigPrefix + "StrictHostKeyChecking", "no");

    try {
        fsManager = VFS.getManager();

        opts = new FileSystemOptions();
        SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, check);

        FileObject baseDir = getBase();

        // Create a folder, if it does not exist or throw an
        // exception, if baseDir is not a folder
        baseDir.createFolder();

        if (!baseDir.isWriteable()) {
            String msg = "Content store base directory is not writeable: " + uri;
            throw new MCRConfigurationException(msg);
        }
    } catch (FileSystemException ex) {
        throw new MCRException(ex.getCode(), ex);
    }
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:28,代碼來源:MCRCStoreVFS.java

示例5: fileMove

import org.apache.commons.vfs2.FileObject; //導入方法依賴的package包/類
/**
 * Move the file
 *
 * @param destination    New location of the folder
 * @param remoteFile     Location of the file
 * @param messageContext The message context that is processed by a handler in the handle method
 * @param manager        Standard file system manager
 */
private void fileMove(String destination, FileObject remoteFile, MessageContext messageContext,
                      StandardFileSystemManager manager) throws IOException {
    FileObject file = manager.resolveFile(destination, FileConnectorUtils.init(messageContext));
    if (FileConnectorUtils.isFolder(file)) {
        if (!file.exists()) {
            file.createFolder();
        }
        file = manager.resolveFile(destination + File.separator + remoteFile.getName().getBaseName(),
                FileConnectorUtils.init(messageContext));
    } else if (!file.exists()) {
        file.createFile();
    }
    remoteFile.moveTo(file);
}
 
開發者ID:wso2-extensions,項目名稱:esb-connector-file,代碼行數:23,代碼來源:FileMove.java

示例6: folderMove

import org.apache.commons.vfs2.FileObject; //導入方法依賴的package包/類
/**
 * Move the folder
 *
 * @param destination            New location of the folder
 * @param source                 Location of the folder
 * @param messageContext         The message context that is processed by a handler in the handle method
 * @param includeParentDirectory Boolean type
 * @param manager                Standard file system manager
 */
private void folderMove(String source, String destination, String filePattern, boolean includeParentDirectory,
                        MessageContext messageContext, StandardFileSystemManager manager) throws IOException {
    FileObject remoteFile = manager.resolveFile(source, FileConnectorUtils.init(messageContext));
    FileObject file = manager.resolveFile(destination, FileConnectorUtils.init(messageContext));
    if (StringUtils.isNotEmpty(filePattern)) {
        FileObject[] children = remoteFile.getChildren();
        for (FileObject child : children) {
            if (child.getType() == FileType.FILE) {
                moveFileWithPattern(child, destination, filePattern, manager, messageContext);
            } else if (child.getType() == FileType.FOLDER) {
                String newSource = source + File.separator + child.getName().getBaseName();
                folderMove(newSource, destination, filePattern, includeParentDirectory, messageContext, manager);
            }
        }
    } else if (includeParentDirectory) {
        file = manager.resolveFile(destination + File.separator + remoteFile.getName().getBaseName(),
                FileConnectorUtils.init(messageContext));
        file.createFolder();
        remoteFile.moveTo(file);
    } else {
        if (!file.exists()) {
            file.createFolder();
        }
        remoteFile.moveTo(file);
        remoteFile.createFolder();
    }
}
 
開發者ID:wso2-extensions,項目名稱:esb-connector-file,代碼行數:37,代碼來源:FileMove.java


注:本文中的org.apache.commons.vfs2.FileObject.createFolder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。