当前位置: 首页>>代码示例>>Java>>正文


Java FileUtil.copyFile方法代码示例

本文整理汇总了Java中org.openide.filesystems.FileUtil.copyFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.copyFile方法的具体用法?Java FileUtil.copyFile怎么用?Java FileUtil.copyFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.filesystems.FileUtil的用法示例。


在下文中一共展示了FileUtil.copyFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyFiles

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Messages({"# {0} - file location", "FileChooserAccessory_no_such_file=Cannot copy nonexistent path {0} to libraries folder."})
private void copyFiles(List<File> files, FileObject newRoot) throws IOException {
    List<File> fs = new ArrayList<File>();
    for (File file : files) {
        FileObject fo = FileUtil.toFileObject(file);
        if (fo == null) {
            throw Exceptions.attachLocalizedMessage(new FileNotFoundException(file.toString()), FileChooserAccessory_no_such_file(file));
        }
        FileObject newFO;
        if (fo.isFolder()) {
            newFO = copyFolderRecursively(fo, newRoot);
        } else {
            FileObject foExists = newRoot.getFileObject(fo.getName(), fo.getExt());
            if (foExists != null) {
                foExists.delete();
            }
            newFO = FileUtil.copyFile(fo, newRoot, fo.getName(), fo.getExt());
        }
        fs.add(FileUtil.toFile(newFO));
    }
    copiedRelativeFiles = getRelativeFiles(fs);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:FileChooserAccessory.java

示例2: copyClassPathExtensionJar

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
 * Copies given JAR file into <tt>release/modules/ext</tt> folder under <tt>projectDir</tt>.
 * <tt>release/modules/ext</tt> will be created if necessary.
 *
 * @param projectDir Project folder
 * @param jar JAR file to be copied
 * @return If JAR copied successfully, returns string array <tt>{&lt;runtime-relative path&gt, &lt;binary origin path&gt;}</tt>,
 * otherwise <tt>null</tt>.
 * @throws IOException When <tt>release/modules/ext</tt> folder cannot be created.
 */
public static String[] copyClassPathExtensionJar(File projectDir, File jar) throws IOException {
    String[] ret = null;

    File releaseDir = new File(projectDir, CPEXT_BINARY_PATH); //NOI18N
    if (! releaseDir.isDirectory() && !releaseDir.mkdirs()) {
        throw new IOException("cannot create release directory '" + releaseDir + "'.");    // NOI18N
    }
    
    FileObject relDirFo = FileUtil.toFileObject(releaseDir);
    FileObject orig = FileUtil.toFileObject(FileUtil.normalizeFile(jar));
    if (orig != null) {
        FileObject existing = relDirFo.getFileObject(orig.getName(), orig.getExt());
        if (existing != null)
            existing.delete();
        FileUtil.copyFile(orig, relDirFo, orig.getName());
        ret = new String[2];
        ret[0] = CPEXT_RUNTIME_RELATIVE_PATH + orig.getNameExt();    // NOI18N
        ret[1] = CPEXT_BINARY_PATH + orig.getNameExt(); // NOI18N
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ApisupportAntUtils.java

示例3: testParseJSFLibraryRegistryV2

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testParseJSFLibraryRegistryV2() throws IOException {
    FileObject fo = FileUtil.toFileObject(new File(getDataDir(), "org.eclipse.wst.common.project.facet.core.xml"));
    FileObject dest = FileUtil.createFolder(new File(getWorkDir(), "ep/.settings/"));
    FileUtil.copyFile(fo, dest, fo.getName(), fo.getExt());
    Facets facets = ProjectParser.readProjectFacets(new File(getWorkDir(), "ep/"), 
        Collections.<String>singleton("org.eclipse.wst.common.project.facet.core.nature"));
    assertNotNull(facets);
    assertEquals(3, facets.getInstalled().size());
    assertEquals("jst.java", facets.getInstalled().get(0).getName());
    assertEquals("6.0", facets.getInstalled().get(0).getVersion());
    assertEquals("jst.web", facets.getInstalled().get(1).getName());
    assertEquals("2.4", facets.getInstalled().get(1).getVersion());
    assertEquals("jst.jsf", facets.getInstalled().get(2).getName());
    assertEquals("1.1", facets.getInstalled().get(2).getVersion());
    facets = ProjectParser.readProjectFacets(new File(getWorkDir(), "ep/"), 
        Collections.<String>singleton("org.XXX"));
    assertNull(facets);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ProjectParserTest.java

示例4: testParseJSFLibraryRegistryV2

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testParseJSFLibraryRegistryV2() throws IOException {
    FileObject fo = FileUtil.toFileObject(new File(getDataDir(), "JSFLibraryRegistryV2.xml"));
    FileObject dest = FileUtil.createFolder(new File(getWorkDir(), "wk/.metadata/.plugins/org.eclipse.jst.jsf.core/"));
    FileUtil.copyFile(fo, dest, fo.getName(), fo.getExt());
    Workspace wk = new Workspace(new File(getWorkDir(), "wk"));
    WorkspaceParser parser = new WorkspaceParser(wk);
    parser.parseJSFLibraryRegistryV2();
    List<String> libContent = wk.getUserLibraries().get("my-jsf");
    assertNotNull(libContent);
    assertEquals(6, libContent.size());
    assertEquals("/home/david/netbeans-6.1/enterprise6/modules/ext/jsf-1_2/commons-beanutils.jar", libContent.get(0));
    assertEquals("/home/david/netbeans-6.1/enterprise6/modules/ext/jsf-1_2/commons-collections.jar", libContent.get(1));
    libContent = wk.getUserLibraries().get("last-one");
    assertNotNull(libContent);
    assertEquals(1, libContent.size());
    assertEquals(new File(wk.getDirectory(), "smth/smthC.jar").getPath(), libContent.get(0));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:WorkspaceParserTest.java

示例5: defineIDE

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static void defineIDE(final String netbeansInstallation) throws IOException {
    FileObject settingsXml = FileUtil.toFileObject(MavenCli.DEFAULT_USER_SETTINGS_FILE);
    if (settingsXml == null) {
        settingsXml = FileUtil.copyFile(FileUtil.getConfigFile("Maven2Templates/settings.xml"), FileUtil.createFolder(MavenCli.DEFAULT_USER_SETTINGS_FILE.getParentFile()), "settings");
    }
    Utilities.performSettingsModelOperations(settingsXml, Collections.<ModelOperation<SettingsModel>>singletonList(new ModelOperation<SettingsModel>() {
        public @Override void performOperation(SettingsModel model) {
            Profile netbeansIde = model.getSettings().findProfileById("netbeans-ide");
            if (netbeansIde != null) {
                return;
            }
            netbeansIde = model.getFactory().createProfile();
            netbeansIde.setId("netbeans-ide");
            Activation activation = model.getFactory().createActivation();
            // XXX why does the model not have this property??
            QName ACTIVE_BY_DEFAULT = SettingsQName.createQName("activeByDefault", model.getSettingsQNames().getNamespaceVersion());
            activation.setChildElementText("activeByDefault", "true", ACTIVE_BY_DEFAULT);
            netbeansIde.setActivation(activation);
            org.netbeans.modules.maven.model.settings.Properties properties = model.getFactory().createProperties();
            properties.setProperty("netbeans.installation", netbeansInstallation);
            netbeansIde.setProperties(properties);
            model.getSettings().addProfile(netbeansIde);
        }
    }));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:RunIDEInstallationChecker.java

示例6: rememberConfigurations

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void rememberConfigurations () {
    FileObject fo = project.getProjectDirectory().getFileObject(ProjectConfigurations.CONFIG_PROPS_PATH);
    if (fo != null) {
        //Has configurations
        try {
            FileSystem fs = FileUtil.createMemoryFileSystem();
            FileUtil.copyFile(fo, fs.getRoot(),fo.getName());
            fo = project.getProjectDirectory().getFileObject("nbproject/private/configs");      //NOI18N
            if (fo != null && fo.isFolder()) {
                FileObject cfgs = fs.getRoot().createFolder("configs");                         //NOI18N
                for (FileObject child : fo.getChildren()) {
                    FileUtil.copyFile(child, cfgs, child.getName());
                }
            }
            configs = fs;
        } catch (IOException ioe) {
            Exceptions.printStackTrace(ioe);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ProjectOperations.java

示例7: testTheCopyProblem

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testTheCopyProblem() throws Exception {
    clearWorkDir();
    
    URL.setURLStreamHandlerFactory(new ProxyURLStreamHandlerFactory());

    File tempFileSource = new File(getWorkDir(), "source");
    tempFileSource.mkdirs();
    File tempFile1 = File.createTempFile("test.test1", "", tempFileSource);
    tempFile1.delete();
    tempFile1.mkdir();
    File tempFile2 = File.createTempFile("test.test2", "", tempFileSource);
    tempFile2.delete();
    tempFile2.mkdir();

    File tempFileTarget = new File(getWorkDir(), "target");
    tempFileTarget.mkdir();

    FileObject sourceFo = FileUtil.toFileObject(tempFileSource);
    FileObject targetFo = FileUtil.toFileObject(tempFileTarget);

    FileUtil.copyFile(sourceFo, targetFo, "source");       

    assertNotNull(targetFo.getFileObject("source/" + tempFile1.getName()));
    assertNotNull(targetFo.getFileObject("source/" + tempFile2.getName()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:FolderCopyProblemTest.java

示例8: copyJnlpImplTemplate

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public static boolean copyJnlpImplTemplate(Project proj) throws IOException {
    boolean res = false;
    final FileObject projDir = proj.getProjectDirectory();
    FileObject jnlpBuildFile = projDir.getFileObject(JNLP_BUILD_IMPL_PATH);
    if (jnlpBuildFile != null && !isJnlpImplUpToDate(proj)) {
        // try to close the file just in case the file is already opened in editor
        DataObject dobj = DataObject.find(jnlpBuildFile);
        CloseCookie closeCookie = dobj.getLookup().lookup(CloseCookie.class);
        if (closeCookie != null) {
            closeCookie.close();
        }
        final FileObject nbproject = projDir.getFileObject("nbproject");                    //NOI18N
        final FileObject backupFile = nbproject.getFileObject("jnlp-impl_backup", "xml");   //NOI18N
        if (backupFile != null) {
            backupFile.delete();
        }
        FileUtil.moveFile(jnlpBuildFile, nbproject, "jnlp-impl_backup");                    //NOI18N
        jnlpBuildFile = null;
    }
    if (jnlpBuildFile == null) {
        FileObject templateFO = FileUtil.getConfigFile(BUILD_TEMPLATE);
        if (templateFO != null) {
            FileUtil.copyFile(templateFO, projDir.getFileObject("nbproject"), "jnlp-impl"); // NOI18N
        }
        res = true;
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:JWSProjectPropertiesUtils.java

示例9: instantiate

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
public java.util.Set<DataObject> instantiate(org.openide.loaders.TemplateWizard templateWizard) throws java.io.IOException {
    File projectLocation = (File) wiz.getProperty(WizardProperties.PROJECT_DIR);
    if(projectLocation == null) {
        warnIssue204880("Wizard property " + WizardProperties.PROJECT_DIR + " is null."); // NOI18N
        throw new IOException(); // return to wizard
    }
    String name = (String) wiz.getProperty(WizardProperties.NAME);
    if(name == null) {
        warnIssue204880("Wizard property " + WizardProperties.NAME + " is null."); // NOI18N
        throw new IOException(); // return to wizard
    }
    String platformName = (String) wiz.getProperty(JavaFXProjectUtils.PROP_JAVA_PLATFORM_NAME);
    if(platformName == null) {
        warnIssue204880("Wizard property " + JavaFXProjectUtils.PROP_JAVA_PLATFORM_NAME + " is null."); // NOI18N
        throw new IOException(); // return to wizard
    }
    FileObject templateFO = templateWizard.getTemplate().getPrimaryFile();
    FileObject prjLoc = JavaFXSampleProjectGenerator.createProjectFromTemplate(
            templateFO, projectLocation, name, platformName);
    java.util.Set<DataObject> set = new java.util.HashSet<DataObject>();
    set.add(DataObject.find(prjLoc));

    // open file from the project specified in the "defaultFileToOpen" attribute
    Object openFile = templateFO.getAttribute("defaultFileToOpen"); // NOI18N
    if (openFile instanceof String) {
        FileObject openFO = prjLoc.getFileObject((String) openFile);
        set.add(DataObject.find(openFO));
    }
    // also open a documentation file registered for this project
    // and copy the .url file for it to the project (#71985)
    FileObject docToOpen = FileUtil.getConfigFile(
            "org-netbeans-modules-javafx2-samples/OpenAfterCreated/" + templateFO.getName() + ".url"); // NOI18N
    if (docToOpen != null) {
        docToOpen = FileUtil.copyFile(docToOpen, prjLoc, "readme"); // NOI18N
        set.add(DataObject.find(docToOpen));
    }

    return set;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:JavaFXSampleProjectIterator.java

示例10: deepCopy

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void deepCopy(FileObject source, FileObject targetDirectory) throws IOException {
    for (FileObject child : source.getChildren()) {
        if (child.isFolder()) {
            FileObject target = targetDirectory.createFolder(child.getNameExt());
            
            deepCopy(child, target);
        } else {
            FileUtil.copyFile(child, targetDirectory, child.getName());
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:GeneratorTestBase.java

示例11: deepCopy

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void deepCopy(FileObject source, FileObject target) throws IOException {
    List toCopy = new LinkedList();
    
    FileObject[] children = source.getChildren();
    
    for (int cntr = 0; cntr < children.length; cntr++) {
        toCopy.add(children[cntr].getNameExt());
    }
    
    while (toCopy.size() > 0) {
        String copying = (String) toCopy.remove(0);
        FileObject toCopyFO = source.getFileObject(copying);
        FileObject targetParent   = target.getFileObject(FileUtil.getRelativePath(source, toCopyFO.getParent()));
        
        if (toCopyFO.isFolder()) {
            targetParent.createFolder(toCopyFO.getNameExt());
            
            children = toCopyFO.getChildren();
            
            for (int cntr = 0; cntr < children.length; cntr++) {
                toCopy.add(FileUtil.getRelativePath(source, children[cntr]));
            }
        } else {
            FileUtil.copyFile(toCopyFO, targetParent, toCopyFO.getName(), toCopyFO.getExt());
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:JavaFreeformFileBuiltQueryTest.java

示例12: addArchivesToProject

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public static void addArchivesToProject(Project project, FileObject targetSource,
        List<FileObject> jars, String classPathType) {
    if (targetSource == null) {
        targetSource = getSourceRoot(project);
    }
    ClassPath classPath = ClassPath.getClassPath(targetSource, classPathType);
    if (classPath != null) {  //hack for PHP
        try {
            FileObject wsClientsSubDir = getWebServiceClientLibraryDir(project);
            ArrayList<URL> archiveJars = new ArrayList<URL>();
            for (FileObject jarFO : jars) {
                try {
                    FileObject destJar = wsClientsSubDir.getFileObject(jarFO.getNameExt());
                    if (destJar == null) {
                        destJar = FileUtil.copyFile(jarFO, wsClientsSubDir, jarFO.getName());
                    }
                    if (classPath.contains(destJar)) {
                        continue;
                    }
                    archiveJars.add(new URL(destJar.getURL().toExternalForm() + "/")); // NOI18N

                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                }
                URL[] archiveURLs = archiveJars.toArray(new URL[archiveJars.size()]);
                ProjectClassPathModifier.addRoots(archiveURLs, targetSource, classPathType);
            }

        } catch (IOException ioe) {
            Exceptions.printStackTrace(ioe);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:LibrariesHelper.java

示例13: copy

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private FileObject copy(FileObject source) throws IOException {
    FileObject fo = p.getProjectDirectory();
    //target/nb-private/tesng-suite.xml
    FileObject folder = FileUtil.createFolder(fo, "target/nb-private"); //NOI18N
    FileObject cfg = folder.getFileObject("testng-suite", "xml"); //NOI18N
    if (cfg != null) {
        cfg.delete();
    }
    return FileUtil.copyFile(source, folder, "testng-suite"); //NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:MavenTestNGSupport.java

示例14: createFromTemplate

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public FileObject createFromTemplate(
    FileObject orig, FileObject f, String n,
    Map<String, Object> p
) throws IOException {
    origObject.add(orig);
    fileObject.add(f);
    name = n;
    parameters = p;

    return FileUtil.copyFile(orig, f, name);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:CreateFromTemplateHandlerTest.java

示例15: copyAdditionalData

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
protected void copyAdditionalData() throws Exception {
    super.copyAdditionalData();
    FileObject out = packageRoot;
    FileObject src = FileUtil.toFileObject(getDataDir());
    src = src.getFileObject("org/netbeans/test/java/hints/pkg");
    FileUtil.copyFile(src, out, src.getName());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ErrorHintsTest.java


注:本文中的org.openide.filesystems.FileUtil.copyFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。